A lunar eclipse occurs when the Earth moves directly between the Sun and the Moon, casting a shadow on the lunar surface.