Dr. Ryan Stone, a biomedical engineer from Lake Zurich, Illinois, is aboard the NASA Space Shuttle Explorer for her first space mission, STS-157. Veteran astronaut Matt Kowalski is commanding his final mission. During a spacewalk to service the Hubble Space Telescope, Mission Control in Houston warns the team about a Russian missile strike on a defunct satellite, which has inadvertently caused a chain reaction forming a cloud of debris in space. Mission Control orders that the mission be aborted and the crew begin re-entry immediately because the debris is speeding towards the Shuttle. Communication with Mission Control is lost shortly thereafter.
High-speed debris from the Russian satellite strikes the Explorer and Hubble, detaching Stone from the shuttle and leaving her tumbling through space. Kowalski, using a Manned Maneuvering Unit (MMU), recovers Stone and they return to the Explorer. They discover that it has suffered catastrophic damage and the rest of the crew is dead. They decide to use the MMU to reach the International Space Station, which is in orbit about 1,450 km (900 mi) away. Kowalski estimates they have 90 minutes before the debris field completes an orbit and threatens them again.
On their way to the International Space Station, the two discuss Stone's home life and her daughter, who died young in an accident. As they approach, they see that its crew has evacuated in one of its two Soyuz TMA capsules. The parachute of the remaining Soyuz TMA-14M has deployed, rendering the capsule useless for returning to Earth. Kowalski suggests using it to travel to the nearby Chinese space station Tiangong, 100 km (60 mi) away, in order to board a Chinese module to return safely to Earth. Out of air and maneuvering power, the two try to grab onto the ISS as they fly by. Stone's leg gets entangled in the Soyuz's parachute cords and she grabs a strap on Kowalski's suit, but it soon becomes clear that the cords will not support them both. Despite Stone's protests, Kowalski detaches himself from the tether to save her from drifting away with him, and she is pulled back towards the ISS while Kowalski floats away to certain death. He continues to support her until he is out of communications range.
Stone enters the space station via an airlock. She cannot re-establish communication with Kowalski and concludes that she is the sole survivor. Inside, a fire breaks out, forcing her to rush to the Soyuz. As she maneuvers the capsule away from the ISS, the tangled parachute tethers prevent it from separating from the station. She spacewalks to release the cables, succeeding just as the debris field completes its orbit and destroys the station. Stone aligns the Soyuz with Tiangong but discovers that its engine has no fuel.
After a poignant attempt at radio communication with an Eskimo–Aleut-speaking fisherman on Earth, Stone resigns herself to being stranded and shuts down the cabin's oxygen supply to commit suicide. As she begins to lose consciousness, Kowalski enters the capsule. Scolding her for giving up, he tells her to rig the Soyuz's soft landing jets to propel the capsule toward Tiangong. Stone then realizes that Kowalski's reappearance was a hallucination, but has nonetheless given her the strength of will to continue. She restores the flow of oxygen and uses the landing jets to navigate toward Tiangong on momentum.
Unable to maneuver the Soyuz to dock with the station, Stone ejects herself via explosive decompression and uses a fire extinguisher as a makeshift thruster to travel the final metres to Tiangong, which is rapidly deorbiting. Stone enters the Shenzhou capsule just as Tiangong starts to break up on the upper edge of the atmosphere. Stone radios that she is ready to head back to Earth. After re-entering the atmosphere, Stone hears Mission Control, which is tracking the capsule and sending a rescue. But due to a harsh reentry and the premature jettison of the heat shield, a fire is starting inside the capsule.
After speeding through the atmosphere, the capsule lands in a lake, but dense smoke forces Stone to evacuate immediately after splashdown. She opens the capsule hatch, allowing water to enter and sink it, forcing Stone to shed her spacesuit and swim ashore. She then watches the remains of the Tiangong re-enter the atmosphere and takes her first shaky steps back on land.