He underwent a rigorous programme of swimming and running and was subjected to long periods of weightlessness. A special suit and helmet were made to withstand the extreme conditions in space.
As perilous as early space travel was, it seemed doubly dangerous for a human being to "walk" - or, more precisely, to float - outside the safety of the capsule. On March 18, 1965, Leonov took that step.
He left the capsule through a hatch, leaving a fellow cosmonaut, Pavel Belyayev, to pilot the ship. Leonov entered an airtight chamber called an air lock and inhaled pure oxygen for almost an hour to reduce the level of nitrogen in his blood, as a means of preventing decompression sickness, or the bends.
Finally, he opened the outer hatch and entered space, more than 161km above the Earth's surface, connected to his capsule by a 5m-long tether. A skilled amateur painter, Leonov found the vista "indescribably beautiful."
"I said to myself, 'It's true, the Earth is round,' " he later said.
His spacewalk was captured by two film cameras that produced remarkably clear images, including some in colour.
"It was so quiet I could even hear my heart beat," Leonov told London's Observer newspaper in 2015. "I was surrounded by stars and was floating without much control. I will never forget the moment. I also felt an incredible sense of responsibility. Of course, I did not know that I was about to experience the most difficult moments of my life - getting back into the capsule."
When he attempted to reenter the air lock leading to the space capsule, Leonov could not climb through the hatch. His spacesuit had expanded and become almost rigid.
"Near the end of my walk," he told the New York Times magazine in 1994, "I realised that my feet had pulled out of my shoes and my hands had pulled away from my gloves. My entire suit stretched so much that my hands and feet appeared to shrink."
He decided that his only option was to open a valve to release air from inside his spacesuit. It deflated enough to allow Leonov to enter the capsule's air lock headfirst, but the change in pressure left him at risk of decompression sickness. His spacewalk lasted only 12 minutes, but his body temperature had risen so much that sweat was sloshing in the leggings of his spacesuit.
"I didn't report this down to Earth," Leonov said in 1999. "I knew the situation better than anyone else."
It would be decades before the dangers he encountered were fully known. Leonov also revealed, years later, that he had a suicide pill in his helmet, in case he could not return to the spacecraft.
Once he was back inside the capsule, it began to roll uncontrollably. Oxygen levels in the cabin became dangerously high, but eventually the cosmonauts were able to stabilise the craft for its return to Earth.
When the automated reentry system failed, Leonov and Belyayev flew their craft manually, tumbling wildly until its parachutes opened. They came to rest in a dense forest in the Ural Mountains, about 1600km from their intended landing spot.
Surrounded by several metres of snow, the two cosmonauts stayed in the capsule as temperatures fell below zero. It took more than two days before they were rescued by helicopter.
His feat made Leonov a national hero, and he was expected to be the first person from his country to walk on the moon. Before the United States could do so, Soviet spaceships circled the moon and sent back samples of lunar soil.
But other test flights failed, and the booster rocket designed to propel the Soviets' lunar mission exploded on the launchpad. The space race was won by the United States, culminating in the Apollo 11 mission, which touched down on July 20, 1969, accompanied by astronaut Neil Armstrong's memorable words as he stepped onto the moon's Sea of Tranquility: "That's one small step for man, one giant leap for mankind."
Alexei Arkhipovich Leonov was born May 30, 1934, in the Siberian village of Listvyanka. He was from a large family, and his father, a one-time coal miner and farmer, spent time in a Soviet gulag for dissent.
Young Leonov was transfixed by aviation from an early age and also studied art. He entered the Soviet air force in 1953 and trained as a fighter pilot and parachutist.
In January 1969, Leonov was in a motorcade entering the Kremlin when a man wearing a police uniform opened fire with two automatic handguns. Leonov's limousine was struck by more than a dozen shots, apparently intended for Soviet leader Leonid I Brezhnev, who was in a different car. Leonov's driver was killed.
"I looked down and saw two bullet holes on each side of my coat where the bullets had passed through," Leonov said in 1994. "A fifth bullet passed so close to my face I could feel it go by."
In 1975, Leonov returned to space as part of the first joint U.S.-Soviet space effort. His capsule docked with an Apollo spacecraft under the command of Nasa astronaut Thomas Stafford. They shook hands through a connecting portal and became close friends.
"In the eyes of all of humanity," Leonov said, "we showed the best side of man."
Survivors include his wife, Svetlana, two daughters and several grandchildren.
Leonov became director of the Soviet cosmonaut corps and retired in 1992. He later worked in banking and exhibited his paintings worldwide, including at the National Air and Space Museum in Washington.
Fluent in English and fond of jokes, he was a popular speaker at gatherings of space aficionados. Author Arthur C Clarke named a spacecraft after Leonov in his 1982 novel, 2010, a sequel to 2001: A Space Odyssey.
Leonov came to regret the secrecy and suspicion surrounding the Cold War competition in space.
"If we could have gotten together earlier," he said in 1990, "we would already have built an international observatory on the Moon and we would be flying to Mars right now."