SOLAR REFRACTION BY EARTH'S ATMOSPHERE
The direction of light changes when it approaches and passes through a medium of a different refractive index at an angle other than perpendicular. Thus, when sunrise or sunset sunlight approaches the earth from the vacuum of outer space and passes through the earth's atmosphere, it is bent inward towards the surface of the earth. This phenomena is called refraction.
The amount of this bending will vary depending upon how much atmosphere the light passes through, which will vary with latitude (larger at higher latitudes) and atmospheric conditions (greater for high pressure areas, presence of water vapor, etc.)
A typical value for this refraction is approximately 34 minutes, or about the same as the apparent diameter of the sun (32 minutes).
Thus, the leading edge of the sun at sunrise is viewed before the sun actually rises, and the trailing edge of the sun appears to set after the sun has already actually set.
This phenomena also acts as a filter, allowing the viewing of the leading (trailing) edge of the sun by the naked eye.
This phenomenon also acts as a prism, bending the higher energy ultra-violet waves less than the lower energy waves. This causes two phenomena. First, the first (last) light that will be observed is in the blue green end of the spectra, leading to what is known as the "blue flash". This may be observed just before sunrise or just after sunset, lasting for only approximately one second. (Click here to see a NASA picture of this at sunset.) Second, it causes both sun rises and sunsets to have a more reddish color since the blue end of the spectrum has been bent further into the earth and disappears first.