Step outside after the first storm after a dry spell and it invariably hits you: the sweet, fresh, powerfully evocative smell of fresh rain.

If you’ve ever noticed this mysterious scent and wondered what’s responsible for it, you’re not alone.

Back in 1964, a pair of Australian scientists (Isabel Joy Bear and R. G. Thomas) began the scientific study of rain’s aroma in earnest with an article in Nature titled “Nature of Agrillaceous Odor.” In it, they coined the term petrichor to help explain the phenomenon, combining a pair of Greek roots: petra (stone) and ichor (the blood of gods in ancient myth).

In that study and subsequent research, they determined that one of the main causes of this distinctive smell is a blend of oils secreted by some plants during arid periods. When a rainstorm comes after a drought, compounds from the oils—which accumulate over time in dry rocks and soil—are mixed and released into the air. The duo also observed that the oils inhibit seed germination, and speculated that plants produce them to limit competition for scarce water supplies during dry times.

These airborne oils combine with other compounds to produce the smell. In moist, forested areas in particular, a common substance is geosmin, a chemical produced by a soil-dwelling bacteria known as actinomycetes. The bacteria secrete the compound when they produce spores, then the force of rain landing on the ground sends these spores up into the air, and the moist air conveys the chemical into our noses.

“It’s a very pleasant aroma, sort of a musky smell,” soil specialist Bill Ypsilantis told NPR during an interview on the topic. “You’ll also smell that when you are in your garden and you’re turning over your soil.”

Because these bacteria thrive in wet conditions and produce spores during dry spells, the smell of geosmin is often most pronounced when it rains for the first time in a while, because the largest supply of spores has collected in the soil. Studies have revealed that the human nose is extremely sensitive to geosmin in particular—some people can detect it at concentrations as low as 5 parts per trillion. (Coincidentally, it’s also responsible for the distinctively earthy taste in beets.)

Ozone—O 3, the molecule made up of three oxygen atoms bonded together—also plays a role in the smell, especially after thunderstorms. A lightning bolt’s electrical charge can split oxygen and nitrogen molecules in the atmosphere, and they often recombine into nitric oxide (NO), which then interacts with other chemicals in the atmosphere to produce ozone. Sometimes, you can even smell ozone in the air (it has a sharp scent reminiscent of chlorine) before a storm arrives because it can be carried over long distances from high altitudes.

But apart from the specific chemicals responsible, there’s also the deeper question of why we find the smell of rain pleasant in the first place. Some scientists have speculated that it’s a product of evolution.

Anthropologist Diana Young of the University of Queensland in Australia, for example, who studied the culture of Western Australia’s Pitjantjatjara people, has observed that they associate the smell of rain with the color green, hinting at the deep-seated link between a season’s first rain and the expectation of growth and associated game animals, both crucial for their diet. She calls this “cultural synesthesia”—the blending of different sensory experiences on a society-wide scale due to evolutionary history.

It’s not a major leap to imagine how other cultures might similarly have positive associations of rain embedded in their collective consciousness—humans around the world, after all, require either plants or animals to eat, and both are more plentiful in rainy times than during drought. If this hypothesis is correct, then the next time you relish the scent of fresh rain, think of it as a cultural imprint, derived from your ancestors.