As the sun sinks into the Pacific, its last light seems to glow green. This "green flash," caused by light refracting in the atmosphere, is rarely seen. But Nigella Hillgarth, the director of the Birch Aquarium at the Scripps Institution of Oceanography in San Diego, got lucky one night.

A green flash is a phenomenon in which part of the sun appears to suddenly change color for about 1 or 2 seconds. The brief flash of green light is seen more often at sunset than at sunrise.

This fleeting spectacle is caused by the refraction of sunlight, which is particularly significant at sunset and sunrise, when the light travels through more of the Earth's atmosphere. The atmosphere bends the sunlight passing through it, separating the light into its different colors, much like a prism bends and splits sunlight into rainbows, according to Cornell University.

The various colors of light bend different amounts based on their wavelengths; shorter wavelengths (blue, violet and green) refract more strongly than longer wavelengths (yellow, orange and red). As such, blue and violet light are scattered by the atmosphere while red, orange and yellow are absorbed, leaving the green light the most visible during the few seconds when the sun sets below or rises above the horizon.

However, green flashes are not always green, according to Andrew T. Young at San Diego State University.

Sometimes, when the air is especially clear, enough of the blue or violet light rays make it through the atmosphere and create a blue flash instead of a green one. Nonetheless, green is the most common hue reported and captured in photos.

There are four categories of green flashes: inferior mirage, mock mirage, subduct flash and green ray, according to an article published by the American Association for the Advancement of Science (AAAS). Nearly all green-flash sightings fall into the first two categories.

Inferior mirage flashes are oval and flat and occur close to sea level when the surface of the water is warmer than the air above it. [Image Album: Strange & Shining: Gallery of Mysterious Night Lights]

Mock mirage flashes, on the other hand, occur higher up in the sky and when conditions on the surface are colder than the air above. The flashes appear to be thin, pointy strips being sliced from the sun, and they last about 1 to 2 seconds.

Subduct flashes are created when the sun appears to form an hourglass shape due to a phenomenon called atmospheric inversion, which occurs when a layer of warm air traps cool air and moisture close to the ground. In this rare circumstance, the upper section of the sun may appear green for up to 15 seconds.

The rarest type of green flash is known as a green ray. In this instance, a beam of green light shoots straight up a few degrees from the green flash immediately after the sun sets for about a second. It's caused by the combination of hazy air and an unusually bright inferior, mock or subduct green flash.

How to see a green flash

While there isn't an optimal condition that will guarantee a green flash sighting, the best way to potentially observe one is to go somewhere that provides a clear view of the horizon and is free of pollution, such as over the ocean, according to Young.

Green flash sightings frequently occur at the ocean, where more of the atmosphere is visible and the line of sight is virtually parallel to the horizon. Flat prairies and deserts also tend to have the appropriate conditions for a green flash sighting. Sometimes, conditions are so perfect that a rare double green flash can be observed.

Polar explorer Adm. Richard Byrd and his crew claimed to have seen a "green sun" persist for 35 minutes while on an expedition to Antarctica in 1929, according to Young. Scientists now believe that there must have been some mirage effect present for the phenomenon to go on for that length of time.

Additional resources:

This article was updated on Jan. 3, 2019, by Live Science contributor Rachel Ross.