The history of pharmaceuticals is full of chance encounters and quirky events. Alexander Fleming stumbled across penicillin when it grew as a mold in his messy lab. Viagra was intended to treat hypertension before researchers noticed, ahem, certain side effects. But perhaps no drug has as peculiar an origin story as Pergonal, a hormonal fertility treatment responsible for millions of babies.

Piero Donini, a scientist working in the late 1940s for the Italian pharmaceutical company that would later be known as Serono, was the first to extract and purify FSH and LH, the hormones that stimulate ovulation. The hormones are found in women’s urine, which is why pregnancy tests can be conducted on urine samples. After experimenting with urine from pregnant women, Donini discovered the highest levels of the hormone actually were in post-menopausal women. After menopause, when ovaries stop producing eggs, FSH and LH shoot up as the body tries to stimulate their production.

Donini called his new substance Pergonal, after the Italian “per gonadi,” or “from the gonads,” and speculated that it could be used to treat infertility. But while Donini had a drug, he didn’t have a market or method of producing it. His paper announcing the discovery languished in obscurity, according to A Tale of Two Hormones, a 1996 book published by Serono about the drug.

It wasn’t until a decade later that scientists exploring infertility heard of Donini’s work, and he was contacted by Bruno Lunenfeld, a Vienna-born, Israeli-educated medical student working in Geneva who was researching the use of human hormones to stimulate pregnancy. Lunenfeld made the case to Serono’s executives for producing enough of the drug to run a clinical trial. One problem: the drug would require thousands of gallons of urine from menopausal women. The young Lunenfeld went before Serono’s board of directors to lobby for the drug. As he later told the Israeli newspaper Haaretz:

“I, just a kid, had to stand before the board of directors and ask them to help us find 400 menopausal women that would agree to collect their urine daily. I gave my lecture, they all applauded politely and then the chairman of the board got up and said: Very nice, but we are a drug factory not a urinal factory. I ran out crying.”

Lunenfeld, the son of a prominent Jewish family from Austria, said his interest in fertility was motivated in part by the need of Jews to replenish their population after the Holocaust. He was then introduced by a Serono executive to Giulio Pacelli, an Italian aristocrat and the nephew of Pope Pius XII. Pacelli, a Serono board member, took an interest in Lunenfeld’s work, and after additional meetings, returned with Lunenfeld to speak with the board of directors.

“Prince Pacelli gave exactly the same speech I had given 10 days earlier, but at the end he added one sentence: `My uncle, Pope Pius, has decided to help us and to ask the nuns in the old-age home to collect urine daily for a sacred cause.’ That, of course, convinced the board of directors immediately to help our research project with money and resources. I later discovered that the Vatican owned 25 percent of Serono.”

Soon, tanker trucks were hauling the pee of hundreds of nuns from Catholic retirement homes across Italy to Serono’s headquarters in Rome. It took about 10 nuns 10 days to produce enough urine for one treatment. While the urine of any post-menopausal women would work, nuns provided Serono with an extra advantage: Because hormones from pregnant women would contaminate the batch, it was critical there be no chance any of the women were pregnant. Working with nuns improved the odds.

In 1962, a woman treated by Lunenfeld with Pergonal in Tel Aviv gave birth to a baby girl, the first child born from the treatment. Within two years, another 20 pregnancies had been achieved with Pergonal, and by the mid-1980s, demand had grown so that Serono needed 30,000 liters a day to produce sufficient quantities of the drug. With shortages appearing, the company began to synthesize the hormones in labs and the resulting treatment, Gonal-f, was first approved in 1995. Serono was acquired in 2007 by Merck, which continues to produce the drug today.

Correction: An earlier version of this article used the incorrect initials in one of the references to the hormones that stimulate ovulation. They are FSH and LH.