Before the movie "Gravity," before Neil Armstrong set foot on the moon, even before Edward Higgins White became the first American to take a walk in orbit — there was Alexei Leonov.

Nearly 50 years ago, on March 18, 1965, cosmonaut Leonov became the first person to ever walk in outer space. The Soviet cosmonaut's spacewalk represented a great leap for humankind, as well as a significant one-up in the Space Race between the Soviet Union and the US.

But this triumphant tale of human ingenuity obscures the far more complex and fascinating story of how Leonov's spacewalk, and his return to Earth, nearly cost him his life, he told the BBC in an amazing feature.

Alexei Leonov describing his historic spacewalk in a recent BBC interview. BBC The purpose of the mission was simple: To perform a spacewalk before the US, who, as the Soviets knew, were preparing for the task.

Everything started to go wrong for Leonov almost immediately upon leaving the Voskhod 2 spacecraft that carried him and his pilot, Pavel Belyayev, into orbit. After 10 minutes of clambering around on the outside of the spacecraft, he received the order to return.

He recounted his terrifying experience to the BBC:

At this point the cosmonaut realised something was wrong. The lack of atmospheric pressure in space had slowly caused his spacesuit to inflate like a balloon. He recalls:

"My suit was becoming deformed, my hands had slipped out of the gloves, my feet came out of the boots. The suit felt loose around my body. I had to do something."

"I couldn't pull myself back using the cord. And what's more with this misshapen suit it would be impossible to fit through the airlock."

In five minutes he would be in the Earth's shadow, and plunged into total darkness.

Without telling ground control, the cosmonaut decided to bleed half of the air out of his spacesuit through a valve in its lining.

This risked starving his body of oxygen, but if he couldn't get back inside the capsule, he'd be dead anyway.

Alexei Leonov faced death at virtually every stage of the Voshkod 2 mission. BBC That was only the first mishap in a harrowing series of them.

As Leonov siphoned the oxygen out of his suit, he began to experience decompression sickness, or "the bends" — the same malady experienced by scuba divers who return too quickly to the surface, caused by a rapid change in pressure that produces gas bubbles inside one's muscles.

He struggled to haul himself back into the craft, nearly giving himself heatstroke in the process, and flooding his helmet with globes of sweat that obscured his vision. Leonov then reentered the craft head-first, not feet first, meaning he had to turn himself around in a tight space in order to pull in the "umbilical cord" that had kept him from careening off into space, and to close the hatch.

Here's what the reentry into the Voskhod 2 spacecraft is supposed to look like. This isn't what Leonov experienced, though:

Rendering of the Voshkod 2 spacecraft. The design calls for the spacewalker to exit head first and re-enter feet first, but in his struggle to get back inside, Leonov re-entered head first. BBC As Leonov told the BBC, "It was the most difficult thing: I'm in this suit and I had to turn around in the airlock. But with the perspiration, I couldn't see anything." He continued: "I don't normally sweat much, but on that day I lost 6kg in weight."

This suit kept Alexei Leonov alive in the vacuum of space. It also nearly killed him. BBC From there the story only gets more incredible. An equipment failure forced Leonov and Belyayev to fire the rockets manually for re-entry, a precision task typically reserved for a computer; one small mistake would have cost them their lives. They made it — only to crash-land in the Siberian woods, surrounded by predators and the unforgiving cold.

For the full story, check out the excellent feature at the BBC's website.