Michael Collins, Buzz Aldrin and Neil Armstrong seen inside the Mobile Quarantine Facility during the 2.5-day trip back to port on the USS Hornet, which picked them up when they splashed down.

It would have been the ultimate contingency of Apollo 11 : What if the astronauts returning home unleashed upon Earth something dangerous and foreign to science — moon germs?

Before Apollo 11 set out, NASA couldn't be positive that, if bits of dust or potential microorganisms got loose back home, life on Earth would be safe. Needless to say, accidentally setting a lunar plague loose on the inhabitants of Earth would have erased all the good publicity garnered by accomplishing the moon landing in the first place. Just in case, in addition to the protections they were establishing to make sure the moon rocks remained free of terrestrial contamination, NASA decided to establish a three-week quarantine for the crew of Apollo 11.

"Initially, NASA thought that all they really needed was a clean room to handle the packaging of the lunar samples in a vacuum," Judith Hayes, chief of NASA's biomedical research and environmental sciences division, told Space.com. "They started really wrapping their head around this, is my understanding. They said, 'We've really never done this before, so we're not really sure,' even though I think most of the scientists didn't firmly believe that there might be a risk."

Related: Apollo 11 at 50: A Complete Guide to the Historic Moon Landing

The quarantine was treated all along as a better-safe-than-sorry operation. The day before Apollo 11 splashed down, support staff had already entered quarantine in Houston to prepare for the crew's arrival, and The New York Times reported : "Twelve men are in absolute quarantine here because of something that probably does not exist."

The problem was, though, if that threat turned out to be a reality, things would get very ugly. "The quarantine program was created out of an abundance of caution," Jason Schwartz, a historian of medicine at the Yale School of Public Health, told Space.com. "You had a very, very small risk of something that could be very, very, very significant."

When the Apollo missions were launching, public health professionals had generally moved on from crude tools like quarantines, he said. "By the 1960s, we were really in the golden age of vaccines and immunizations," Schwartz said, particularly for diseases like polio, measles and mumps. "There was great optimism that the war against infectious diseases was being won," and he said that could have contributed to a fear of backsliding if Apollo went very wrong.

And the prospect of moon germs also mirrored a real public health concern at the time, of novel pathogens that the population had never had a chance to build an immunity to. It's a fear that remains with us today, which was sparked at the time by, for example, new influenza strains popping up on occasion. If something nasty hitched a ride back from the moon, it would have been the epitome of a novel pathogen. And, it would have driven doctors and public health practitioners way beyond their comfort zone.

Related: The Weirdest Things Apollo Astronauts Left on the Moon

"This was a different story than most public health efforts at the time, because typically, when we think about treatments, antibiotics, vaccines, quarantines, we're thinking about known viruses or bacteria with distinct symptoms, distinct modes of transmission that we know about and we can apply that knowledge to figure out how to tailor the public health response," Schwartz said. "In this case, it was responding to an unknowable, responding to a very slim but still nonzero uncertainty. How do you tailor a public health response when you're not sure what exactly you're concerned about or what it looks like or how it might affect humans at all?"

In the absence of any precisely honed tools to combat the potential threat, NASA used the blunt approach of a quarantine. The details of the plan were based on tackling a disease like the plague, according to a 1999 oral history given by Charles Berry, who was in charge of medical operations during Apollo.

The quarantine procedures began three weeks before launch, when the astronauts went into isolation to reduce the odds they would catch anything that NASA would later need to identify as terrestrial or lunar. For Apollo 11, Berry said, the prelaunch quarantine was nearly derailed by President Richard Nixon , who wanted to eat dinner with the crew the evening before launch. It was Berry's job to explain why that simply wasn't an option — the closest he said he believed he ever came to being fired.

"If [the astronauts] came down with anything, whatever it was, a cough, a sniffle, or anything else, we were going to have to prove that it didn't come from the moon," Berry told the interviewer. "So I think it would be pretty stupid to let somebody just walk into that situation. It would have been a total breakdown of the program."

(Astronauts today are also quarantined before their launch , but only because carrying terrestrial germs into orbit would be deeply unpleasant.)

Nixon shooed off and quarantine preserved, the trio of astronauts climbed aboard their rocket and blasted off on the historic journey. As they wrapped up their time on the moon, Neil Armstrong and Buzz Aldrin abandoned some of their equipment , including their boot covers, in part to reduce the odds they would bring back any lunar threats. The 21-day quarantine clock began ticking as soon as the pair stepped off the moon and closed the hatch on the lunar module.

They rejoined their colleague, Michael Collins, and headed back to Earth, splashing down in the Pacific Ocean on July 24. But the astronauts still had more than two weeks of quarantine left, and NASA had decided it wasn't safe to simply hoist the newly returned command module onto the aircraft carrier sent to fetch the astronauts.

The rescue crew had to send a swimmer to the spacecraft to open the hatch and throw in biological isolation garments for the astronauts to put on — spacesuits for Earth use only, essentially, with tightly woven fabric that would contain particles; rubber gloves; and a built-in breathing system.

The quarantine procedure began with biological isolation garments, which the Apollo 11 crew donned while leaving the command module and wore until they entered the Mobile Quarantine Facility seen in the right foreground. (Image credit: NASA)

That made splashdown the biggest weakness in the quarantine system, as Collins has said in interviews looking back at the mission . "When you open that hatch, we had stuff come into the air, without any question about it," Berry said in his oral history. "You know, if it had been lunar plague, I don't know what would have happened. I didn't believe we were going to have lunar plague, but I couldn't go on the basis that we weren't."

Once the astronauts had donned their isolation suits, they climbed on board the ship sent to rescue them, then into the Mobile Quarantine Facility, a trailer NASA had converted to house them. The crew spent 2.5 days in the trailer as they sailed to port in Hawaii, then boarded a plane to Houston. Back in NASA's astronaut headquarters, the trailer was connected to the Lunar Receiving Laboratory, a special facility the agency had built at what is now the Johnson Space Center.

The building included quarantine quarters as well as lab space for preparing and studying moon rocks . The crew section was large enough to hold more than 100 people if something went very wrong, Hayes said, and included a kitchen, a lounge, a library and a collection of surgical and medical examination rooms.

Neil Armstrong celebrated his 39th birthday on Aug. 5, 1969, while still in quarantine. According to NASA the cake was "standard two-layer, plain vanilla" and decorated with 39 candles. (Image credit: NASA)

"It was, I think, quite comfortable," Hayes said. "Talking to the crews from back then and the flight surgeon, they did say that — you know, it wasn't bad. After spending time in a capsule, being in the quarantine facility was quite comfortable." Armstrong even celebrated his birthday in the quarantine building.

The crew and about 20 companions waited out the rest of the quarantine period in the facility, without particular concerns about the possibility they were infected. "I got the impression that … the [astronauts] were not worried," Hayes said. "They had daily exams from their flight surgeons … they were being carefully watched by the flight surgeons and the scientists in the quarantine." Scientists were also monitoring mice that had been exposed to lunar samples in case they showed signs of distress, but all did well.

But by the end of the 21 days, newspapers reported that the astronauts were ready to get back to exploring Earth. "I'm ready any time they want to open that door," Aldrin said according to The New York Times . "Take my blood. Marvelous idea. Why didn't I think of that sooner?" the paper reported Collins said when it transpired that a blood test would shorten quarantine by a few hours.

NASA had planned to institute the quarantine for Apollo 11, 12, 13 and 14, then reevaluate the situation. The Apollo 13 quarantine was canceled after the crewmembers were forced to skip the moon landing maneuver. During the first couple years of studying moon rocks in terrestrial labs, occasional lapses in safety protocols also sent scientists into observation or quarantine.

Wives and children of the Apollo 12 crew greet the returning astronauts in their Mobile Quarantine Facility. The crew quarantine procedures were used for Apollo 11, 12 and 14, then deemed unnecessary. (Image credit: NASA)

But after Apollo 14, NASA decided that Earth was safe from lunar bugs. The lunar receiving lab's sample-processing side remained active until a new building was constructed and the moon rocks were moved out. Then, the building was turned over to NASA's life sciences division, which is how Hayes ended up spending decades working in its labs and uncovering its history.

Now, her department has moved out as well. "I was the last one to shut the lights out and lock the door when we moved out of the Lunar Receiving Lab, and now it sits empty," Hayes said.

According to NASA spokesperson Noah Michelsohn, the building is slated for demolition, with a new sample-processing facility due to be built before the asteroid missions OSIRIS-REx and Hayabusa2 bring back new, precious space rocks starting late next year. Hayes said she wishes she had appreciated the facility more when she first joined NASA, since it tells such a compelling story about the Apollo program and of spaceflight in general.

"It's kind of amazing, all the things they thought of and pulled together to do this," Hayes said. "I imagine when we go back to the moon, we'll have to do some similar things, not necessarily for the crew but handling samples and the experiments that'll be done."