Fry accidentally ties his only pants to a weather balloon Professor Farnsworth releases to gather data on a bizarre series of weather patterns on Earth. He then shoots the weather balloon down to retrieve his pants, which land in Central Park, only to be taken away by a Central Park badger. As the Planet Express crew follows the badger, with Leela breaking her leg when Fry tries to save her from falling, the crew discovers an ancient Martian pyramid and calendar predicting that the world is going to end in 3012. Based on the data gathered from the weather balloon, Professor Farnsworth finds out that the Sun is going to release a solar flare that will destroy Earth.
An electromagnetic storm then strikes Earth, rendering all electrical appliances, including spaceships useless. But Amy finds out that the pyramid they discovered is actually a spaceship that can hold 30,000 people and runs on snakes. The crew tried to test the spaceship for themselves, but was caught by Zapp and brought before President Nixon. The President then decides that a Decision Making Machine is to be used to select the most optimal cross-sections of humanity to be taken to Mars where they will start life anew. Fry is selected for his 'lucky pants' while Leela is rejected due to Zapp being the pilot of the spaceship. Before boarding begins, Fry disguises his ticket as one for Leela and decides to remain on Earth with Bender, who stays to loot.
After arriving at Mars, where they are greeted by Amy's parents, Leo and Inez, the humans are approached by Singing Wind, who clarifies that the solar flare will actually strike Mars, not Earth as speculated as the solar flare will bypass Earth and reach Mars. Amy is then blamed over the predicament, saying that she got mixed up between the Ancient and Modern Martian language in trying to decipher the ancient Martian calendar.
The humans attempt to escape, but can't because Zapp has dismantled the stone spaceship to build a memorial for those who stayed behind Earth. As the solar flare strikes Mars, it ignites the gases contained in its crust and causes it to propel towards Earth. The humans manage to jump off Mars back onto Earth as it goes within yards of their home planet. However, Leela is unable to jump back due to her broken leg. Fry then climbs on top of the Planet Express building hoping to catch Leela as Mars passes by but they only manage to tear off each other's arms in the process. Later, it is revealed that Scruffy rescued Leela with a ladder. With Mars still on Earth's orbit, Professor Farnsworth uses the birth machine first seen on "Rebirth" to make new arms for Fry and Leela while their torn off arms are then shown floating off in space, held to each other.