Glynn S. Lunney, one of NASA’s first flight directors, who had a major role in guiding astronauts to the moon and whose cool decision-making under pressure helped save the Apollo 13 mission in 1970 after an onboard explosion, died March 19 at his home in Clear Lake, Tex. He was 84.

The death was announced in a statement by NASA. He had been treated for several years for leukemia.

Mr. Lunney joined the space program during its infancy in the 1950s and helped develop the Mercury spacecraft used in the first U.S. crewed flights in the early 1960s. He was the fourth person selected to be a NASA flight director, a job he described as the “leader of all that went on in mission control, and all of the stuff that went up to the flight crews by way of recommendations and decisions.”

He was such a devoted protege of Christopher C. Kraft Jr., the space agency’s renowned flight operations director, that he was sometimes called “the son of Chris Kraft.”

Mr. Lunney was a leading behind-the-scenes figure in the Gemini and Apollo crewed flight programs of the 1960s. In 1968, he became the chief of NASA’s flight director’s office, responsible for supervising other flight directors and training the many flight controllers and engineers who worked at what is now the Johnson Space Center in Houston.

He was one of four flight directors for Apollo 11, the 1969 mission on which astronauts Neil Armstrong and Edwin “Buzz” Aldrin became the first people to set foot on the moon.

The next year, he was one of four flight directors for Apollo 13, along with Milton Windler, Gerald D. Griffin and Eugene Kranz. The mission, with astronauts Jim Lovell, Fred Haise and Jack Swigert, was scheduled to go to the moon.

They were 80 percent of the way to their destination on April 13, 1970, when “all of us heard a rather large bang,” Lovell later said. It turned out that wires from a fan had struck metal inside one of the spacecraft’s two oxygen tanks, sparking an explosion.

“Houston,” Swigert memorably said to mission control, “we’ve had a problem here.”

Before Mr. Lunney’s shift began about 10 p.m., he later said in a NASA documentary, “we were well aware that we had a big problem on our hands. It was life-threatening. It was not about landing on the moon in the right place. It was about survival.”

Kranz, who was portrayed in the 1995 film “Apollo 13” by Ed Harris, is rightly given credit for his calmness under pressure and for working to save the mission from disaster. In reality, it took an effort by all four flight directors and dozens of flight controllers to diagnose the problem and devise a way to bring Apollo 13 back safely, through 250,000 miles of space.

(Mr. Lunney did not appreciate the movie: “They didn’t give me credit for any of the work that I did,” he said in 2019. “As a matter of fact, if you watch the movie, you’ll see I’m sort of portrayed as a flunky.”)

After the initial report of distress on April 13, Mr. Lunney and his team worked for 14 hours straight, calling it “the longest night” in the history of the space program.

“I had a brief period when the severity of the problem really struck home,” he said in a NASA oral history. “For the first and only time in 10 years of console experiences in training and actual flights, I had the sense of the bottom falling out from under me and my stomach heading for that dark hole. . . . But the 10 years of experience kicked in and it took about 10-20 seconds for me to return from that place. Nobody else even seemed to notice.”

With the command module’s electrical system failing, the three astronauts moved to the smaller lunar module, a fragile craft built for only two. Apollo 13 circled the moon, then made a course correction as it swung back toward Earth. By some calculations, the spacecraft would run out of fuel before it could return. Its guidance and radio systems were used sparingly to conserve battery power and dwindling supplies of oxygen and water. The astronauts spent more than three days in temperatures barely above freezing.

Mr. Lunney considered five possibilities for where the Apollo should land before concluding that the best plan was to bring the spacecraft down in the Pacific Ocean, near U.S. Navy ships and helicopters.

Before the craft’s reentry into Earth’s atmosphere, the crew shifted back to the command module because it had a heat shield to protect it from extremely high temperatures. The lunar module, where the astronauts had holed up for days, was jettisoned. Much of the world was watching on television when the crippled spaceship splashed down on April 17.

“For four days,” Lovell’s wife, Marilyn, said, “I didn’t know if I was going to be a wife or a widow.”

The entire support team in Houston, including Mr. Lunney, received the Presidential Medal of Freedom. Astronaut Ken Mattingly, who was bumped from the flight because of possible exposure to measles, later called Mr. Lunney’s unflappable leadership of his flight team “professionalism at its finest, absolutely the most magnificent performance I’ve ever watched.”

Glynn Stephen Lunney was born Nov. 27, 1936, in Old Forge, Pa. His father was a coal miner and welder, his mother a homemaker.

After two years at the University of Scranton in Pennsylvania, Mr. Lunney transferred to the University of Detroit (now the University of Detroit Mercy), where he studied engineering and took part in a cooperative training program with a forerunner of NASA. He joined the space agency after his graduation in 1958.

Mr. Lunney was a flight director for several Gemini missions before working on the Apollo program. He was technical director of the Apollo-Soyuz project in 1975, when U.S. and Soviet astronauts linked up in space. He later worked on the Skylab and space shuttle projects before leaving NASA in 1985. He worked in the space programs of Rockwell International and United Space Alliance until retiring in 1998. One of his sons, Bryan Lunney, also became a NASA flight director.

Survivors include his wife since 1960, the former Marilyn Kurtz of Clear Lake; four children; two brothers; a sister; and 12 grandchildren.

In his NASA oral history, Mr. Lunney looked back on the dramatic rescue of Apollo 13 as “the best piece of operations work I ever did or could hope to do.”

“We built a quarter-million mile space highway,” he added, “paved by one decision, one choice, and one innovation at a time — repeated constantly over almost four days to bring the crew safely home. This space highway guided the crippled ship back to planet Earth, where people from all continents were bonded in support of these three explorers-in-peril. It was an inspiring and emotional feeling, reminding us once again of our common humanity.”