Mirage is caused due to total Internal Reflection of light by the various layers of air.
Mirage is an optical phenomenon which creates an illusion of the presence of water and is a result of refraction of light from a non-uniform medium. Mirage is observed mainly during sunny days when driving on a roadway.
When the light rays from the sun travel straight through the atmosphere, these light rays travel at different speeds through the hot and cold air. For mirage to occur the ground should be very hot and the surrounding air cold. The layer which is above the ground gets warmed. The light ray gets refracted when the light moves through the cold air and into the hot air layer. This is how mirage occurs.