Whenever two objects or regions at different temperatures are in contact (or can exchange energy via radiation), energy flows spontaneously from the hotter region to the cooler region. This is a consequence of the second law of thermodynamics: heat always flows down a temperature gradient.
Consider a hot cup of tea placed on a cool table. Energy is continuously transferred from the tea (higher temperature) to the table and the surrounding air (lower temperature). The tea cools down and the surroundings warm up slightly, until both reach the same temperature.
As energy is transferred from the hotter region to the cooler region, the temperature difference between them gradually decreases. The rate of energy transfer slows as the temperature difference becomes smaller. Eventually, both regions reach the same temperature — this is thermal equilibrium. At this point, there is no longer a net flow of energy between the two regions.
Thermal equilibrium does not mean that energy transfer has stopped completely. At the microscopic level, particles continue to collide and exchange energy. However, the rate of energy transfer in one direction equals the rate in the other, so there is no net change in temperature for either region.
Temperature is a measure of the average kinetic energy of the particles in a substance. A region of higher temperature has particles with greater average kinetic energy. When two regions are in contact, collisions between their particles lead to a transfer of kinetic energy from those with more (the hotter region) to those with less (the cooler region), until the average kinetic energies — and therefore temperatures — are equalised.
Thermal equilibrium is encountered in many everyday situations: