Arthur Dent awakes one day to find a demolition crew outside his house, preparing to bulldoze it down to make way for a new bypass. He throws himself down in front of the bulldozer to try to stop the demolition. Shortly after, his friend Ford Prefect arrives, suggests he has something very important to tell Arthur, and convinces him to leave his desperate protest and get a drink. Ford is secretly from a small planet near Betelgeuse and works as a researcher for The Hitchhiker’s Guide to the Galaxy, a quirky galactic repository of knowledge.
Ford has discovered that a Vogon Constructor fleet is heading toward Earth to destroy it to make way for a galactic bypass. The fleet arrives, causing mass chaos on Earth. Its leader, Prostetnic Jeltz, announces that Earth has been scheduled for demolition and unceremoniously destroys it. Ford manages to hitch a ride for himself and Arthur on Jeltz’s starship, where Arthur learns about Ford’s true origins, The Hitchhiker’s Guide to the Galaxy, and the usefulness of towels. A search party soon arrives and takes Ford and Arthur to Jeltz, who doesn’t like hitchhikers. Jeltz delights in watching Ford and Arthur suffer while he reads them his poetry and forces them to critique it. Ford and Arthur’s critiques disappoint Jeltz, and he orders them to be thrown out an airlock. Ford and Arthur are, against the odds, picked up by a starship called the Heart of Gold a second before they suffocate in the vacuum of space.
The two-headed, three-armed, impetuous Zaphod Beeblebrox became Galactic President to steal the Heart of Gold and its unique Infinite Improbability Drive, a propulsion system that allows the starship to travel through all points in the galaxy in less than a second. Zaphod is accompanied by Trillian, a young woman from Earth whom Arthur once tried to pick up at a party. The Heart of Gold is equipped with a depressed robot named Marvin and controlled by a cheerful computer named Eddie. The starship’s drive creates a wake of improbability when it is activated, and for this reason, the Heart of Gold picked up Ford and Arthur on its own. Ford and Arthur awake onboard the starship and experience several impossibly strange events. When normality is reestablished, Zaphod sends Marvin to bring Ford and Arthur to the bridge, where Zaphod and Ford recognize each other: The two are semi-cousins and close friends. Arthur recognizes Zaphod as Phil, the man who spirited Tricia McMillian, now known as Trillian, away from him at a party six months earlier.
The Infinite Improbability Drive brings the crew to Magrathea, a legendary planet that had once designed custom planets for the galaxy’s wealthiest inhabitants. The starship begins to descend to the planet’s surface, which triggers the planetary defense system, launching two nuclear missiles at the Heart of Gold. Despite taking evasive action, the starship cannot outrun the missiles. At the last second, Arthur turns on the Infinite Improbability Drive in the hope of avoiding certain death, and the missiles turn into a bowl of petunias and a sperm whale. The Heart of Gold lands on Magrathea, where Zaphod discovers an entrance into Magrathea’s interior. Leaving Arthur and Marvin to stand guard, Zaphod, Trillian, and Ford search the tunnels, where Zaphod explains that he discovered that he tampered with his own memories to prevent himself from realizing why he wanted to find Magrathea. A door suddenly slams down, trapping the group. The tunnel fills with gas, and Zaphod, Ford, and Trillian pass out.
While standing guard, Arthur encounters Slartibartfast, a Magrathean. The two travel in an aircar to Slartibartfast’s office, where he reveals that Earth was an organic supercomputer designed by a pandimensional race and built by the Magratheans. Millions of years ago, an alien race created a supercomputer named Deep Thought, which was given the single purpose of figuring out the answer to the Ultimate Question of Life, the Universe, and Everything. At the end of its seven-and-a-half-million-year program, Deep Thought reveals that the answer is “forty-two.”
Sensing the disappointment from this answer, Deep Thought builds an organic computer to discover the true Ultimate Question, which will hopefully make sense of the answer. This new organic computer was Earth, but it was destroyed by the Vogons mere minutes before it completed its ten-million-year task.
Slartibartfast continues to explain that Magrathea has been awakened to build a second Earth—Earth Mark Two—and that the pandimensional beings who commissioned the creation of the original Earth manifest in Arthur’s dimension as mice.
Upon awaking, Zaphod recalls a missing memory. He explains that Yooden Vranx, the Galactic President before Zaphod, suggested that Zaphod become Galactic President and steal the Heart of Gold. Zaphod, Ford, and Trillian are then taken to meet the mice, where they will soon reunite with Arthur. Frankie mouse and Benjy mouse explain to Arthur that the question they have waited ten million years for may reside in his brain, and they offer to buy it from him. Arthur refuses, and Frankie and Benjy try to take the answer by force as alarms sound and chaos ensues. Barely escaping from the mice, Arthur, Ford, Trillian, and Zaphod search for a way out of Magrathea.
Meanwhile, Frankie and Benjy come up with a plausible lie to sell to the rest of their pandimensional species. After Zaphod stole the Heart of Gold, two Blagulon Kappa police officers tracked him to Magrathea and enter the planet’s interior attempting to apprehend him. The officers corner Zaphod, Ford, Arthur, and Trillian in a computer room and shoot at them. Suddenly, both officers drop dead. Their life support systems inexplicably exploded.
Zaphod, Ford, Arthur, and Trillian make it back to the Heart of Gold and Marvin, who’s been lying on the ground, depressed. The group boards the starship, leaves Magrathea, and heads to the Restaurant at the End of the Universe to get something to eat.