Media playback is unsupported on your device Media caption John Young became an astronaut in 1962

US astronaut John Young, who flew to the moon twice and commanded the first ever space shuttle mission, has died aged 87, Nasa said.

"Today, Nasa and the world have lost a pioneer," agency chief Robert Lightfoot said in a statement.

Young was the only person to have flown missions on the Gemini, Apollo and space shuttle programmes.

He also once famously smuggled a corned beef sandwich on to a space flight as a gift for a fellow astronaut.

Young retired in 2004 after a 42-year career. Nasa said he died on Friday following complications from pneumonia.

"John was one of that group of early space pioneers whose bravery and commitment sparked our nation's first great achievements in space," Mr Lightfoot said.

"But, not content with that, his hands-on contributions continued long after the last of his six space flights - a world record at the time of his retirement from the cockpit."

Born in San Francisco in 1930, Young gained a degree in aeronautical engineering at the Georgia Institute of Technology and then served in the US Navy as a test pilot.

He was picked as a Nasa astronaut in 1962 and first went into space in 1965 with the Gemini 3 mission.

Image copyright AFP Image caption John Young, right, commanded the first shuttle mission in 1981, pictured here with crew member Robert Crippen

It was while orbiting the Earth that he handed the smuggled sandwich to his colleague, Gus Grissom. Nasa later rebuked him for the stunt.

In May 1969 Young was part of the Apollo 10 mission that flew to the moon as a rehearsal for the Apollo 11 landing two months later. The crew tested the lander module in lunar orbit without landing it.

Young finally walked on the moon himself in 1972 as commander of the Apollo 16 mission - the ninth of 12 people to have ever set foot on the lunar surface.

He and crewmate Charles Duke gathered rock and soil samples and drove the lunar rover more than 16 miles (26km).

Image copyright EPA Image caption Young, centre, took part in the Apollo 10 mission

In an interview with the Houston Chronicle in 2004, Young recalled: "One-sixth gravity on the surface of the moon is just delightful. It's not like being in zero gravity, you know. You can drop a pencil in zero gravity and look for it for three days. In one-sixth gravity, you just look down and there it is."

In 1981, Young commanded the inaugural flight of Nasa's first space shuttle, Columbia. Two years later he became the first person to fly six space missions when he commanded Columbia on the first Spacelab mission.

It was his last journey into space. Young had been due to command a space shuttle flight in 1986 but it was cancelled after the explosion of the shuttle Challenger earlier that year.