Apollo 11 lunar module pilot Buzz Aldrin stands on the moon near the American flag during NASA's historic first manned moon landing on July 20, 1969. Apollo 11 commander Neil Armstrong took the photo.

Apollo 11 was four minutes into its landing sequence when the terse words of its commander, Neil Armstrong, came from the speaker in Mission Control:

"Program alarm."

Buzz Aldrin, standing next to Armstrong in the descending Lunar Module, stared at the frozen display on the computer, which read "1202." It was an error code, but for what? Controllers in Houston scanned their notes trying to figure out what the heck the problem was. But time was running short. [45th Anniversary of Apollo 11: Complete Coverage]

"Give us a reading on that program alarm," Armstrong said. He sounded tense, but no more so than during the simulations. It was hard to grasp that a life-or-death struggle was playing out 240,000 miles (386,000 kilometers) from Earth, in a small, fragile machine descending rapidly to the moon. Communications were spotty; the computer was threatening to quit, and Gene Kranz, the flight director for this first lunar landing, felt Mission Control slip a bit further behind the power curve.

A risky moonshot

Most people knew that going to the moon was risky. Some outside of Mission Control, listening to the tense communication between the astronauts and Houston, understood what some of the urgency meant. But few, very few, knew the scope of the dangers that the crew faced. These were no longer theoretical; they were being played out in space at that very moment.

Key players in the landing of Apollo 11, including Kranz, related the stakes to me these many decades later. "We would either land on the moon, we would crash attempting to land, or we would abort," he said simply. "The final two outcomes were not good."

That is an understatement on a grand scale.

The Apollo 11 lunar module Eagle is seen from the Columbia command module in this photograph by command module pilot Michael Collins on July 20, 1969. Aboard the Eagle, Apollo 11 commander Neil Armstrong and lunar module pilot Buzz Aldrin prepared to land on the surface of the moon for the first time. (Image credit: NASA)

Approaching the moon

The problems began immediately upon separation from the Command Module in which Armstrong, Aldrin and Michael Collins had ridden to the moon. (Collins would remain in the Command Module as Armstrong and Aldrin landed.) Mission Control was having trouble with the radio link to the Lunar Module.

"It was purely my decision how much information was enough," Kranz recalled. "This is now going through my mind: 'Do I have enough information to continue?' And the answer is yes" — but barely. "I gave the crew the go for powered descent," that is, to beginthe rocket-braked landing, "and we immediately lost communications again."

Aldrin had adjusted the antenna, and Mission Control had done what they could on their end, but the radio connection just kept on fading in and out. If it got much worse, Kranz would have to order an abort. [Apollo 11 Quiz: Are You a Moon Maven?]

As flight controllers on Earth struggled with communication issues and spotty radar data, the master alarm sounded in the LM's cabin, also lighting console warnings in Mission Control. The landing computer was signaling an overload; the 1202 alarm it displayed was an error code that meant, in effect, "I have too much to do, so I am going to stop, reboot and start over." Had this occurred, mission rules would have called for an immediate abort as their ability to navigate the landing would be compromised. The computer was receiving more data than it could handle.

The events startled Aldrin; the code was unfamiliar to him. "We couldn't look it up in the book to see what the problem was 'cause we were watching where we were going!" he said. Neil Armstrong waited a bit, then tersely asked Houston for clarification.

Back on Earth

On the ground, Controller Steve Bales made the call: It was OK to continue, so long as the alarm was intermittent. "In the middle of landing, it was almost as dangerous to try to abort with a bad computer as it was to carry on with the landing," Bales said. "So balancing risk versus risk, we decided that the safest thing would be to continue to land." [Amazing Moon Photos from Apollo 11]

CAPCOM [Capsule Communicator] Charlie Duke, a fellow astronaut, relayed the message to space: "We're go on that alarm!" Then, within minutes, the computer spit out another alarm: 1201. But it was the same class of warning, so they continued. "Same type, we're go," Duke radioed.

At this point, Buzz Aldrin was concentrating on the instrument displays, calling off the numbers for altitude, speed and other critical data as Armstrong took over manual control of the landing.

But there was another problem — they were not where they were supposed to be.

Aldrin recalled: "In the commander's window was a grid, a vertical line with marks on it. And this was calibrated to [Armstrong's] height and his eye level." Taking cues from the computer, the commander could check against this grid to determine the LM's position over the moon. Now, it told them that they were coming in "long," or downrange. Between the lumpy gravity of the moon and some extra speed picked up when they undocked from the Command Module, Armstrong and Aldrin had overshot the predicted landing zone.

An unwelcoming view glared at Armstrong. Where the orbital maps indicated a smooth plain, there was instead a vast crater field and collections of truck-sized boulders. Flying manually and low on fuel, Armstrong leveled off and searched for a smooth spot.

"I was looking at my trajectory plot," Charlie Duke remembers, "[and] Neil leveled off at about 400 feet [122 meters] and was whizzing across the surface … It was far from what we had trained for and seen in the simulations. So I started getting a little nervous, and they weren't telling us what was wrong. It was just that they were flying this strange trajectory."

In fact, they were flying for their lives.

Running low on fuel

With a rapidly diminishing fuel supply, they would soon reach the 60-second mark — one minute to a mandatory abort. And it was uncertain whether or not an abort, a forced staging and emergency ignition of the ascent engine, would even be possible at this altitude.

"You never [want to] go under the 'Dead Man's Curve,'" said Controller Bales. "It was an altitude [where] you just don't have enough time to do an abort before you had crashed … Essentially, you're a dead man."

CAPCOM Duke called the 60-second fuel warning. Armstrong focused intently on a smooth spot ahead. Aldrin continued calling out the speed and range. [Buzz Aldrin's Thoughts Just Before Moon Landing (Video)]

"We heard the call of 60 seconds, and a low-level light came on. That, I'm sure, caused concern in the control center," Aldrin recalled with a smile. "They probably normally expected us to land with about two minutes of fuel left. And here we were, still a hundred feet [30 m] above the surface, at 60 seconds."

It was a critical phase. "Then there's another call for 30 seconds," Kranz recalled. "And at about that time, you know, you really start to suck air, and I'm seriously thinking, now we have this land-abort decision that the crew is faced with. Are they going to have sufficient fuel to land on the moon, or are they going to have to abort very close to the lunar surface?"

"When it got down to 30 seconds, we were about 10 feet [3 m] or less" from the surface, Aldrin said. "I could sneak a look out, because at that point, I don't think Neilcared what the numbers were. He was looking at the outside. I could see a shadow of the sun being behind us."

In fact, the descent engine was kicking up so much dust at this altitude that the shadow and a few boulders sticking up through the haze were all Armstrong could use to gauge the remaining distance to the surface.

Then, a long metal rod that extended from the landing legs touched the lunar plain, signaling their arrival. A blue light on the console came on — "CONTACT LIGHT" — and the landing was over.

"Houston, Tranquility Base here … the Eagle has landed," Armstrong said in laconic tones.

Apollo 11, on the moon

In Mission Control, there was a moment of continued silence.

"It took us a couple seconds to really realize that we had made it. And then the people in the viewing room start stomping, and I mean just cheering and clapping and stomping their feet," Kranz remembered. "I'm so tied up emotionally at this time that I literally cannot speak, and I've got to get my team back on track." It took a physical act to get him back to reality. "I rapped my arm on the console — and break my pencil! — and finally get back on track and call my controllers to attention. I say, 'OK, all you flight controllers, settle down. OK. Let's get back on with it.'"

But the moon had more mischief in store, even though the crew had successfully touched down. Armstrong and Aldrin had "safed" the LM, shutting down the landing systems and performing their post-landing checklist. Everything looked good on the moon. But in Mission Control, it was a different story.

Within minutes, the consoles monitoring the Lunar Module's descent stage signaled a potentially dangerous pressure buildup in a descent-engine fuel line.

Dick Dunne, Grumman's PR man for Apollo, recalled the critical moment. The extreme cold from the lunar surface was creeping into the descent stage after engine shutdown. "The cold permeated a fuel line, and caused a blockage … which was immediately reported back by telemetry to Mission Control in Houston. That gave us cause for alarm," he remembered.

A plug of ice was blocking a fuel line. It might melt, or it might cause a relief disk to blow, relieving the pressure. Or it might cause a catastrophic explosion. Nobody could be sure.

Apollo 11 commander Neil Armstrong descends the ladder on the lunar module Eagle on July 20, 1969 in this still image of a live TV broadcast during the first manned moon landing. (Image credit: NASA)

To moonwalk, or not to moonwalk

As Kranz debated whether or not to tell the astronauts, there was a quick conference among the flight controllers and the Grumman reps. "There was some thought given to aborting the exploration of the moon and to initiate the launch sequence right away," Dunne recalled. "However, the heat that came out of the engine melted the ice that had formed, and the problem went away." Pressures in the engine returned to normal. Controllers breathed a heavy sigh of relief, even as the astronauts continued their checklists, unaware.

Within three hours, Armstrong and Aldrin were ready to explore the moon. But as they prepared to exit the Lunar Module, yet another issue cropped up: They could not get all the air out of the LM. The astronauts opened the valve and watched as the oxygen vented out … but even as it read zero, they could not get the hatch open. There was still too much pressure inside the lander.

"We tried to pull the door open, and it wouldn't come open," Aldrin said. "We thought, 'Well, I wonder if we're going to get out or not?' It took an abnormal time for it to finally get to a point where we felt we could pull on a fairly flimsy door." ['Magnificent Desolation': Aldrin's View on the Moon (Video)]

In fact, Aldrin eventually resorted to peeling back one edge of the front hatch … but carefully. "You don't wanna rupture that door and leave yourself in a vacuum for the rest of the mission!" he recalled with a chuckle.

Armstrong maneuvered toward the open hatch, aided by Aldrin. As Armstrong twisted his bulky suit to head out, unheard in the vacuum of the cabin, something small snapped. Armstrong's backpack had broken off the ascent engine arming switch. But upon their preparation to leave the moon some 21 hours later, Armstrong calmly flipped the broken stub with a ballpoint pen. Another crisis averted, this time courtesy of the Fisher Space Pen.

Homeward bound

On July 21, the LM's ascent engine lifted Armstrong and Aldrin back up to Mike Collins in the Command Module. With the crew docked and reunited, their lives depended on one more event critical to leave lunar orbit and head home. The rocket engine at the rear of the Apollo Command/Service module, the SPS, had to ignite to break them free of lunar orbit.

"That service propulsion system has got to work," Kranz said. "Single option, big engine, that's the only thing that's going to get you home." With the LM used up and discarded, there was no backup. Worse yet, the SPS firing would occur when the astronauts were on the far side of the moon and out of contact with Houston. As some controllers would later remember, those last minutes of radio silence were the mission's longest.

The SPS engine fired, and Apollo 11 left the clutches of the moon and sped home to a fiery re-entry on July 24. The entry angle was critical; at 25,000 mph (40,200 km/h), there was not much room for error.

Kranz recalled those final moments of the mission: "It's a difficult time, a lonely time for the controller, because there's only one thought in every controller's mind: 'Did I get them to do everything we needed to? Is my data right?'" He grimaced at the memory. "No more givebacks … We've trained well. They have confidence in us. We have confidence in them. And then it's up to them and the spacecraft to finish off the mission."

Apollo 11's mission ended in the tropical Pacific Ocean, splashing down near Wake Island. In Mission Control, Gene Kranz and his team celebrated by clapping and passing out Churchill cigars. The first manned lunar landing was complete, and five more crews would follow to the moon's surface, conducting increasingly ambitious, and still highly risky, missions. But above it all, in Kranz' memory, is the overwhelming nature of the accomplishment. As he put it, "What America will dare, America will do."

Rod Pyle, an historian and science writer, is the author of "Destination Moon" (2007, Smithsonian Books) and "Missions to the Moon" (2009, Sterling). His latest book is "Curiosity: An Inside Look at the Mars Rover Mission and the People Who Made It Happen" (2014, Prometheus Books). Follow us @Spacedotcom, Facebook and Google+. Original article on Space.com.