The Martian begins in the near (and undated) future. Astronaut Mark Watney is a botanist and mechanical engineer on the American Ares 3 mission to Mars, following two successful Ares missions that have been met first with earthly excitement, then mostly indifference. After a couple days on Mars, a giant dust storm disrupts the astronauts' mission and forces an abort. During this, Watney is struck with a shard of metal—a piece of the crew's own antenna. The crew leaves Watney on Mars, thinking him to be dead after the incident. Commander Lewis, in charge of the mission, does so with a heavy heart, but believes it to be the proper protocol. The Ares 3 crew attempts to maintain morale for the many-months-long trip back to Earth, while NASA does what it can to control fallout, on Earth, from the supposed death of Watney on the Red Planet.
Roughly a day later, however, Watney returns to consciousness, alone on Mars. He hobbles back to the Hab (the astronauts' base) and tends to his injury, a puncture wound in his stomach. He then takes stock of the food, water, and air supplies remaining in the Hab. He plans to severely ration his food, to survive till the next Ares mission, which is slated several years in the future, landing many thousands of kilometers from his current location. Watney discovers that he can recycle almost all the air and water he uses, removing any immediate dangers to his life (although he now depends entirely on the life support systems in the Hab, which were intended for a short stint on the planet).
Mark then explores his means of communication, and realizes that the antenna for the comms satellite is broken. While going through the personal items of his crew members, Watney finds that his only entertainment is a trove of media files from the 1970s, stored on Commander Lewis's hard drive. Watney hates disco, and this becomes a recurring joke throughout the novel.
Back on Earth, a NASA employee named Mindy Park figures out that Watney is still alive, by reviewing satellite images of the mission-site. Sanders, the chief of NASA, and Kapoor, head of the Mars program, consult with Montrose, the public relations director, and Henderson, the immediate boss of the Ares 3 crew. Henderson advocates that NASA should inform the Ares 3 crew, headed back to Earth on the Hermes, that Watney is still alive. But Kapoor and Sanders believe that this information will only upset them, and that the crew must still carry out a fairly complex mission to return safely to Earth. NASA informs the media that Watney is alive, setting off a firestorm around the world, and an outpouring of support on Watney's behalf. Nonstop news coverage ensues, including a show on CNN called "Mark Watney Report," and NASA requests a substantially larger budget from the US government, to devote resources to bringing Mark home.
NASA tries to figure out an effective rescue plan, first believing they can send interim food supplies to Watney, then pick him up at the projected Ares 4 site (called Schiaparelli crater) with a new crew, several years in the future. With the supplies they'll have sent along, they'll be able to supplement Watney's food-stuffs, consisting mostly of the potatoes Watney is able, cleverly, to cultivate, using NASA's seeds and his robust botanical skills.
NASA monitors Mark via updated satellite images from the Martian surface. Watney can leave them messages using rocks and Morse code, but NASA can't talk to him. They watch as he drives out in the rover and retrieves an old unmanned probe called Pathfinder, which he brings back to the Hab and eventually uses to communicate with NASA; the Pathfinder becomes his "modem" and his "radio."
For a short time, it appears Mark's survival and rescue will go smoothly. But then an airlock to the Hab breaks, and Watney is thrown from the structure. Although he is physically unhurt, much of his store of potatoes is damaged, as is his ability to grow future crops. NASA calculates that Watney won't survive until the Ares 4 mission arrives, because of this depleted supply, so they decide to send a faster replacement mission, called Iris, to relieve him in the interim. But NASA rushes the launch, owing to the vast distance between Earth and Mars, and the rocket explodes soon after take-off. The prospects of Watney's rescue have now, over the course of months, gone from bad to worse to dire.
Fortunately, the Chinese space agency can provide a replacement rocket. And a NASA researcher named Purnell has come up with a "maneuver," in secret, which will allow food to reach Watney far more quickly. This plan involves Watney's Ares 3 crew-mates turning around and picking him up from space, after he launches off the surface of Mars. Sanders immediately blocks the idea, fearing it is too dangerous, but Henderson leaks the plan to the crew of Ares 3, who decouple from NASA's control of their vehicle and begin the process of saving Watney on their own—at which point NASA has no choice but to publicly support the Purnell Maneuver.
After an unfortunate accident with a drill, Watney overloads the circuits of the Pathfinder. His comms with NASA are therefore severed, but not before he learns that the Ares 3 crew is coming back for him. Watney has enough information to travel to Schiaparelli on his own, using his knowledge of Martian topography, and his skills as an engineer to modify two rovers to make the long trek. Watney begins the drive to the crater, and manages to avoid a dust storm and survive a tumble in his vehicle. He reaches the crater, and the Ares 4 MAV—the rocket that will launch him into space, where he can make a short "hop" over to the returned Hermes spacecraft.
Watney successfully modifies the Ares 4 MAV, and NASA coordinates his launch. Although Watney has successfully removed a good deal of the craft, making it lighter, the MAV veers off course, prompting the Hermes to adjust its location to meet Watney. Lewis and her crew do just this, and Beck, one of the crew-mates, is able to lift Watney out of the MAV and bring him into Hermes. Watney has suffered a few broken ribs, and the crew members say he smells terrible (after having showered only minimally for years). But Watney is as happy as he's ever been -- he's safe, surrounded by his crew, and headed home.