“I had a lot of confidence,” Mr. Kranz said. “Every time I launched, I believed we would bring them home. It was a confidence.”

But luck also played a role. If the explosion had occurred later in the mission, after the lunar lander with Mr. Lovell and Mr. Haise had already headed to the moon, the separated command module with Mr. Swigert would have been stranded in lunar orbit. Mr. Lovell and Mr. Haise would have been stuck on the moon’s surface with no way home.

That was not the only close call of the Apollo era. During Apollo 11, the lunar lander was nearly out of fuel before Neil Armstrong found a spot to set down. As the Apollo 12 mission got underway, lightning struck the Saturn 5 rocket during liftoff, scrambling electronic systems. Remarkably, the rocket stayed on course as an astute ground controller remembered a switch that rebooted the electronic systems.

What scientists have learned in the last 50 years has minimized many of those risks.

There are now much more detailed maps of the moon’s surface. Launch rules were tightened to avoid a recurrence of a lightning strike, and meteorological tools are now much more capable of detecting a buildup of electrical charge in the atmosphere before lightning discharges.

Under President Trump, the top priority for NASA is to send astronauts back to the moon. Last year, his administration accelerated the timetable for the first crewed landing to 2024 from 2028 (although delays resulting from the coronavirus outbreak have raised fresh doubts about this schedule).

NASA named the new moon program Artemis, after the sister of Apollo in Greek mythology.

Direct comparisons between the Artemis and Apollo missions are difficult to make, because NASA has not yet decided all of the details of how it will land on the moon. Two pieces are set: the giant Space Launch System rocket — a modern-day equivalent of the Saturn 5 that lofted the Apollo crews — and the Orion crew capsule, which is like the Apollo command module, but larger.