A real-estate agent and storm chaser captured a snapshot of a lifetime on Aug. 9, when he photographed a rare duo — an eerie flash of lightning framed by a glorious rainbow — in Tucson, Arizona.

The electrifying image took social media by storm: As of Aug. 14, Greg McCown's photo had garnered more than 1,000 Facebook likes and more than 3,600 retweets.

There's a reason why it went viral: Those types of sightings are incredibly rare. Although 100 lighting bolts strike the Earth every second, the chances of them flashing near a rainbow are slim, said Randall Cerveny, a professor of meteorology at Arizona State University in Tucson.

"Usually, you don't get those two things to line up at the same time," Cerveny said, adding that a desert area like Tucson is more likely to serve up conditions for such a sighting. [Electric Earth: Stunning Images of Lightning]

Lightning

Both phenomena require raindrops, but they use them in different ways.

Lightning bolts illuminate a pathway from the ground to the sky when negatively charged cloud bottoms connect with positive charges on Earth's surface. "When you get a buildup of negative charge in the bottom of a cloud," which occurs when raindrops pull charges down, "opposites attract," Cerveny told LiveScience.

"It's the same kind of thing that happens when you walk across the carpet and touch a door handle," he added.

Unlike the spark from the handle, however, lightning flashes can extend for miles, depending on the altitude of the cloud bottoms. The longest flashes typically occur in the desert because its surface is too dry to support lower-lying clouds, Cerveny said.

Arizona is one of the best places for lightning photography because its cloud bottoms are so high, Cerveny said. The viral photo shows a cloud-to-ground lighting flash, which makes up about 20 percent of all lightning. The majority of lighting occurs within a cloud, or from cloud to cloud — when opposite charges find each other.

Rainbow

Raindrops may shuttle electrical charges to form lightning, but to form a rainbow, raindrops must scatter sunlight, separating the light into the colors that make up a rainbow.

A rainbow results when the light waves bend, or refract, as they pass through raindrops, Cerveny said. Raindrops act as a glass prism would, bending sunlight and forcing it to reveal the individual colors it contains.

The viral photo is especially rare because McCown had to be standing in between the sun and the storm at the exact moment when the angle of the sun hit the raindrops to form a rainbow, and the positive ground charges and negative cloud charges clashed in a flash of lightning.

"It's a pretty rare thing," Cerveny said.

Elizabeth Goldbaum is on Twitter. Follow Live Science @livescience, Facebook & Google+. This story was originally written for LiveScience and was republished with permission here. Copyright 2015 LiveScience, a Purch company.

Related on LiveScience: