Astronaut John Young, who became one of the most accomplished astronauts in the history of the U.S. space program, died at age 87 on Jan. 5. (Reuters)

John Young, NASA’s longest-serving astronaut, who flew in space six times, walked on the moon, commanded the first space shuttle and became the conscience of the astronaut corps, advocating for safety reforms in the wake of the 1986 Challenger disaster, died Jan. 5 at his home in Houston. He was 87.

NASA announced his death, citing complications from pneumonia as the cause.

Mr. Young spent 42 years in the space program and was the only astronaut to go to space as part of the Gemini, Apollo and space shuttle programs. He spent 13 years as chief of the astronaut corps, playing a major role in coordinating spaceflight training, scheduling and safety.

In 1981, when he was named commander of the Columbia, the first space shuttle mission, he said he was recommended for the job by NASA’s chief astronaut.

“And at that time,” he said with a straight face, “I was the chief.”

Astronaut John Young, commander of Apollo 16, standing on the moon in 1972. (HO/AFP/GETTY IMAGES)

Mr. Young was part of the first two-man space flight in 1965, with Virgil “Gus” Grissom aboard Gemini 3. In May 1969, he piloted the command module of Apollo 10 around the moon as a dress rehearsal for the first lunar landing two months later by Apollo 11.

In 1972, as the commander of Apollo 16, Mr. Young became one of only 12 astronauts to set foot on the moon. He and another astronaut, Charles Duke, drove a vehicle 16 miles across the lunar surface, collecting more than 200 pounds of soil samples and rocks.

At one point, the moon buggy’s fender fell off, forcing Mr. Young to become an on-the-spot lunar mechanic. He attached a cardboard map of the moon to the vehicle and continued on his way.

Mr. Young’s decades of experience and low-key manner made him a revered figure among other astronauts.

“If they have a hero, that hero is John Young,” fellow astronaut Robert L. Crippen said in 2004. “No man in the human spaceflight program is more respected.”

Soon after joining the astronaut corps in 1962, Mr. Young was tapped to help develop equipment and protective gear for space flights. When Grissom, his first spaceflight partner, was killed along with two other astronauts in a launchpad fire in 1967, Mr. Young became a forthright voice for astronaut safety.

He and Grissom had spoken about faulty wiring in an early model of the Apollo spacecraft but had not brought their concerns to NASA authorities, for fear of losing their jobs. Mr. Young vowed never to stay silent again.

Astronaut John Young in 1964. (NASA Johnson Space Center)

“Whenever and wherever I found a potential safety issue,” he wrote in a 2012 memoir, “Forever Young,” “I always did my utmost to make some noise about it, by memo or whatever means might best bring attention to it.”

He was particularly outspoken after the space shuttle Challenger exploded 73 seconds after liftoff on Jan. 28, 1986, killing all seven crew members. Mr. Young witnessed the disaster from the air, while aboard a training aircraft.

A NASA inquiry later determined that the explosion was caused, at least in part, by the failure of small rubber O-rings on a particularly cold day. Mr. Young contended that the astronauts were never made aware of such a potentially catastrophic technical problem.

In a scathing 12-page memo, he wrote that NASA management had compromised the astronauts’ safety to move forward with the launch.

“There is only one driving reason that such a potentially dangerous system would ever be allowed to fly — launch-schedule pressure,” he wrote.

Other longtime astronauts shared Mr. Young’s views, but his complaints — and his reputation as a prophet of “doom and gloom,” in his words — rankled NASA’s top brass.

An Air Force colonel in the space program ripped Mr. Young in a letter, charging him with taking a “cheap shot” at NASA and behaving in an “irresponsible, undisciplined and unprofessional manner.”

Within a year, Mr. Young was relieved of his duties as chief of the astronaut corps and assigned to another job at NASA, director of engineering and safety.

In 1983, Mr. Young flew his sixth and final space mission, commanding the Columbia space shuttle. As the spacecraft reentered the Earth’s atmosphere, two of its three auxiliary power units caught fire, and the main computer stopped working.

“Not to mince words, we were on fire when we landed,” he wrote in his memoir, “though of course we didn’t know it at the time.”

Nearly 22 years later, the Columbia — the space shuttle Mr. Young had taken on its maiden voyage in 1981 — broke apart on reentry, killing the seven astronauts onboard.

Mr. Young, who was still officially an astronaut at the time, criticized NASA’s internal culture, suggesting that an emphasis on cost-cutting had contributed to the potential for accidents.

A space shuttle launch, he wrote in his memoir, “always scared me more than it thrilled me.”

John Watts Young was born Sept. 24, 1930, in San Francisco and grew up mostly in Orlando. His father managed a citrus plantation for a time.

After graduating from Georgia Tech in 1952, Mr. Young entered the Navy and became a test pilot. He was part of NASA’s second astronaut corps, which also included Neil Armstrong, the first person to walk on the moon.

Mr. Young had two flights each in the Gemini (1965 and 1966), Apollo (1969 and 1972) and space shuttle (1981 and 1983) programs. He retired from NASA in 2004 after 42 years, the longest tenure of any astronaut.

His first marriage, to Barbara White, ended in divorce. Survivors include his second wife, the former Susy Feldman of Houston; two children from his first marriage; and, according to his website, two grandchildren.

Many of his fellow astronauts left NASA to enter business or public service or simply retreated from the public eye. Mr. Young retained a single-minded devotion to the space program that kept him working 12-hour days into his 70s. His only hobby was staying fit enough to maintain his active flight status.

Early in his NASA career, Mr. Young had a role in testing freeze-dried food for space journeys. He was sometimes critical of the cuisine and once vulgarly complained about the flatulence produced by powdered orange juice.

During his first mission, aboard Gemini 3 in 1965, Mr. Young smuggled aboard a corned beef sandwich. When it was time for the freeze-dried lunch, he handed the sandwich to Grissom as a joke.

NASA officials were aghast and, from then on, strictly prohibited astronauts from taking contraband food on board.

Correction: An earlier version of this story incorrectly reported that John Young’s father served in the Navy Seabees.