People have always thought that humans are the most intelligent species on the planet Earth, but actually they're the third. The second most intelligent species on Earth is the dolphin, who has always known the planet would be destroyed soon. They tried to tell people about it, but their communication attempts were mistaken for tricks.
In the end, all the dolphins left Earth on their own, leaving a simple message behind: so long and thanks for all the fish. Meanwhile in the England countryside, Arthur wakes up to discover his boring routine is being interrupted by a construction crew outside his house, intending to demolish the building. Arthur rushes to lie down on the ground between the house and the crew, arguing with the head engineer because nobody told him anything about this.
The argument is suddenly interrupted by Arthur's best friend Ford, who brings a cart full of beer to distract the crew while he drags Arthur away to the pub. While he has more drinks than usual, Ford starts acting strangely and says he's an alien from another planet. To prove it, he reminds Arthur that they met when Ford tried to introduce himself to a car and Arthur pushed him out of the way just in time.
Ford still feels he owes Arthur for saving his life, and now he wants to save his friend from Earth's incoming end. However Arthur's distracted by a picture on his phone of a woman named Tricia, which makes him sad. He had met her at a party and the two of them had hit it off, but when Tricia asked Arthur to come with her to Madagascar to look for adventure, Arthur turned her down because he liked his peaceful British life.
At that moment a flashy man named Zaphod cut in and took Tricia away, but Arthur never stopped thinking about her. Their chat is interrupted when Arthur hears the sound of demolition and runs back to his house, where he sadly discovers his home is already gone. Suddenly the area is covered by a huge shadow and the crew runs away when a giant spaceship appears in the sky.
Ford isn't surprised, he just hands Arthur a towel and tells him to hold tight while he lifts his thumb, which has a glowing hitchhiking ring that takes them right into the ship. This spaceship is commanded by a bad-tempered and bureaucratic alien species known as Vogons, and at that moment the Vogon captain sends a message to the entire world announcing that there have been plans to build a hyperspace Expressway in the galaxy, so they'll have to destroy Earth to get it out of the way. The planet suddenly finds itself surrounded by Vogon ships and all humans panic right before Earth explodes, only leaving dust behind.
Meanwhile Arthur learns that Ford is a journalist that had been working on the Earth entry for the Hitchhiker's Guide to the Galaxy, a universal guidebook with tips for any planet you may want to visit. The existence of aliens is shocking but Arthur doesn't care, he just wants to go home, so Ford has to inform him the Vogons destroyed Earth. While Ford tries to find a hole in the wall to send a new signal with his ring, Arthur reads about Vogons on the guide, learning they're the most unpleasant species in the universe and that their poetry is a form of torture.
Suddenly the Vogons see both men on the security cameras and immediately send a warning through the speaker, but Arthur can't understand what they're saying. Ford inserts a little fish in his ear and explains it's the Babel Fish, a little alien that will translate everything you hear into words you can understand. A bunch of Vogons show up and capture Arthur and Ford to tie them up for the captain, who proceeds to read poetry to them.
Ford squirms in pain, but Arthur doesn't get what the big deal is, although to be fair he can't even understand the poem. When the captain asks for their opinion, Arthur lies and says it was great, offering a full analysis of the emotional impact. However the captain takes it as an insult and orders that the duo shall get thrown out.
The Vogons ignore Arthur's and Ford's pleas and push them out of the ship, then the duo floats in panic for a few seconds until suddenly, shapes around them begin changing until a spaceship appears. Now Arthur and Ford find themselves shaped as sofas inside this very round ship, but as soon as they scream, they revert to their usual figures. In another part of the ship Zaphod, who turns out to be the President of the Galaxy, is watching the news about how he stole this ship, which is known as the Heart of Gold.
At that moment Tricia interrupts him to announce the system has detected hitchhikers, which the ship picked up by mistake when they used the improbability drive. Zaphod is worried that they may be with the galaxy police force and gets his gun, but Tricia decides to be cautious and sends a robot instead. This robot turns out to be Marvin, who lives in a constant depressed state and can only say negative things about a situation.
Marvin picks up Arthur and Ford and guides them through the ship's corridors, where they notice every door talks as they walk through them. Meanwhile the Vogons set out thousands of ships into hyperspace to go after the Heart of Gold. When Malvin takes the duo to the president, Zaphod's first instinct is to try to shoot them, but he immediately recognizes Ford and the two of them hug because they're distant relatives.
Arthur is in shock because he remembers Zaphod from the party, but Zaphod doesn't have any idea who he is. Then Tricia shows up too and Arthur is delighted to see her, but when he tries to tell her about Earth, Zaphod takes Arthur aside and threatens him into keeping the secret. Arthur is creeped out when he sees Zaphod has a second head hiding in his neck, it turns out that you can't be president with a whole brain so Zaphod carved it out.
He also has an extra hidden arm that he uses to hit Arthur and embarrass him in front of Tricia. Suddenly hundreds of Vogon ships appear out of the blue and the Vogon captain together with the galaxy vice-president asks the group to surrender. Zaphod refuses and makes the ship go into hyperspace, making the Heart of Gold teleport to another spot in the galaxy.
Afterward, Arthur approaches Tricia to catch up and shows how jealous he is that she left with Zaphod. Tricia reveals she's changed her name and shows Arthur all the cool gadgets the ship has, like a machine that reads your mind and makes whatever you're craving. She's always wanted adventure and to leave their little town, so she isn't sorry that she chose Zaphod over Arthur.
When she looks for some medicine for Arthur's wound in her bag, two mice come out of it and flee the kitchen. Then Zaphod shows the group a video to explain why he stole the Heart of Gold. Many years ago, a supercomputer named Deep Thought was built in order to answer the ultimate question of Life, the Universe, and Everything.
It took seven million years for Deep Thought to come up with the answer, which was 42. Nobody understood what it meant, and Deep Thought explained it only knew the answer, so they had to make a better computer to get the ultimate question. Zaphod wants to find the ultimate question for fame, and for that he needs to go to planet Magrathea, which can only be reached with the Heart of Gold's improbability drive through trial and error.
The improbability drive teleports the ship to a random location in the cosmos, and this sometimes causes weird shape-shifting effects on the passengers that go away after a few seconds. This time when Zaphod activates it, the crew transforms into knitted figurines. This distracts Arthur and gives the mice the chance to pluck some hair from his head.
After they return to normal, they discover they've arrived at Viltvodle V, home of Zaphod's political rival. Zaphod wants to pay him a visit, so they land the ship and meet the Jatravartid people, who believe the universe was sneezed out of the nose of a being called the Great Green Arkleseizure. The group interrupts a ceremony praying for the Coming of the Great White Handkerchief and Zaphod meets with his rival Humma to ask him for the coordinates to Magrathea.
Humma is still angry that Zaphod won the election, but accepts to give him the coordinates if Zaphod brings back from Magrathea a legendary gun. Zaphod accepts and to make sure he comes back, Humma takes one of his heads. The group leaves with the coordinates, but when they come out they discover the Vogons surrounding the building.
The Vogons immediately open fire and the group runs to hide behind a column, so Tricia comes up with a plan to escape. She holds up an aerosol can against Zaphod's head and pretends she'll kill him in order for the Vogons to let her pass. Unfortunately the Vogons manage to grab her and arrest her on the spot before opening fire on the guys again.
Ford and Arthur pick up Zaphod and drag him back to the ship to escape. Zaphod tries to make the ship go to Magrathea, but Arthur stops him and asks to be taken to Vogsphere, the homeworld of the Vogons, to save Tricia. The ship's AI informs them the guidance system has been deactivated, which the mice did in secret.
They have no choice but to use a regular escape cop and fly the traditional way. Moments later, the group arrives at Vogsphere. Since Zaphod isn't thinking clearly with only one head, Ford puts a cap on his head on which he must squeeze lemons every few hours to give Zaphod's mind a kick.
Then the men begin making their way to Vogon prison, only to encounter swatters on the ground that hit them every time they take a step. No matter what they try they can't stop them, thus the trio runs through the swatters to reach the building in absolute pain. In the meantime, Tricia is interrogated by the Vogons and she finally learns that Earth was destroyed.
When she wonders how that could've happened, she discovers Zaphod signed the paperwork without even reading it because he thought he was signing an autograph. As punishment for kidnapping the president, it's decided that Tricia will be fed to the Ravenous Bugblatter Beast of Traal. At the front desk, the Vogons put the trio through lots of bureaucratic drivel and constantly ask for more paperwork.
When they're finally done, the Vogon realizes they're trying to bail out Tricia and explains she's not eligible because kidnapping the president is too serious. Arthur and Ford make Zaphord tell them it was all a misunderstanding, and now they have to fill the paperwork all over again using presidential forms. After lots of signing and box-ticking, their request is finally accepted and they save Tricia right before she's fed to the beast.
However Tricia isn't happy to see them and slaps Zaphod for destroying Earth; she's also angry with Arthur for lying to her. The group takes the pod back to the Heart of Gold and while Tricia is taking a shower, Arthur approaches her to apologize and to point out that if he had said yes to Madagascar, then they would've exploded with Earth. Then Zaphod uses the coordinates to make the improbability drive take them to Magrathea, which puts them through a bunch of funny shapes again.
When they come closer to the planet, they receive a pre-recorded message saying the planet has been temporarily closed. Zaphod ignores it and tries to land the ship anyway, causing another message to inform them two missiles have been sent to destroy their ship. The AI hands Zaphod manual controls to dodge the missiles, which makes the entire ship shake like crazy.
Using the improbability drive like this is dangerous, but Arthur decides to press the button anyway. After a short moment of turbulence, they discover they're in the same place, and the drive affected the missiles instead: one became a bowl of petunias and the other transformed into a whale that has an existential crisis before it falls on the planet. Now the group can land and explore Magrathea safely, and they encounter a bunch of different portals.
An argument ensues on which one they should take, and Arthur is still too afraid of the dangers of the unknown. Tricia ignores the guys and jumps into a random portal, so Ford and Zaphod quickly follow her. Arthur keeps on hesitating, and by the time he finally makes up his mind, the portal is already closed.
Arthur sits with Marvin without knowing what to do and is found by a man known as Slartibartfast, who tells Arthur that his friends are safe before taking him away into another portal, leaving Marvin behind. They show up in a room filled with miniature worlds as Slartibartfast explains his job consists of designing and creating planets, and it was his company that created Earth, but the demolition had been an accidental mix-up. Then Slartibartfast takes Arthur to the planet factory and reveals they are finishing a copy of Earth they had in the system backup.
Meanwhile Zaphod, Tricia, and Ford finally reach Deep Thought, only to find the computer watching tv. They ask about the ultimate question, but Deep Thought has bad news: the computer that had the question had been on Earth, meaning it's destroyed. The trio is disappointed but also remembers the other half of the mission and goes looking for the gun, finding it inside the computer.
This is the Point-of-View gun, which makes a person momentarily see things from the perspective of the shooter. It was created by housewives that wanted their husbands to listen to them, therefore women are immune. Tricia immediately shoots Zaphod with it to make him understand why she's angry, but hearing him speak her own thoughts makes Tricia realize that she's upset because she's discovered life is meaningless and that she's been jumping from guy to guy to fill the hole in her heart, yet she ignored the one guy that could truly understand her.
Suddenly a door opens behind them and they see a couple of mice before a light blinds them. Back to Arthur, he hears the story of Earth being a commission paid by mice, who are the most intelligent species on the planet. All this time, mice had been experimenting on humans while letting them believe they were the ones experimenting on the mice.
Then Slartibartfast takes Arthur to a replica of his home, and Arthur happily runs inside only to find Ford, Tricia, and Zaphod at the breakfast table. There are also two talking mice that say they've been observing humans to find life's ultimate question and that they'll need Arthur's actual brain to finish the experiment. Suddenly Arthur is restrained on his chair and two small saws appear to start the procedure while his friends fall asleep because of something that the mice put in the food.
Trying to distract the mice, Arthur begins making philosophical questions, but soon he's unconsciously talking about his own feelings and how much fun he's had the past week compared to his entire previous life. He also talks about Tricia, but since the mice don't care about love they proceed with the saws. At that moment Arthur manages to break the restraints and smashes the mice with a bowl, discovering that their actual identity is the two aliens that created Deep Thought.
Then everyone wakes up as the house starts to shake because hundreds of Vogons have landed outside with the vice-president and Marvin, ready to rescue Zaphod from his supposed kidnappers. The group quickly runs away to hide behind an RV, dropping the gun by accident. When Marvin tries to join them, he gets shot in the back of his head and falls, seemingly dead.
While the group hides inside the RV, the Vogons open fire again and make the RV fall to the ground. When it seems all hope is lost, suddenly Marvin activates again and uses the gun on the Vogons, which instantly makes them all depressed and drop on the floor without the energy to do their jobs. Afterward Slartibartfast shows up to announce the new Earth is finally ready, so he wonders if Arthur thinks there's anything missing.
Arthur says that the only thing missing will be him, then he asks Tricia to join him on the next adventure, and the couple leaves together in the Heart of Gold to visit the Restaurant at the End of the Universe. While Arthur and Tricia kiss, the new Earth is put back in place and the circle of life begins once more. Arthur's final words before the ship leaves are that he won't go anywhere without his towel, and these words accidentally travel through a wormhole that reaches an alien species whose language understands the sentence as an insult.
Furious, the aliens travel to Earth to invade, but it turns out they're so small that their tiny spaceships are swallowed by a dog, proving once again everything is a matter of perspective.