The movie begins just before Shrek (voiced by Mike Myers
) rescues Princess Fiona (voiced by Cameron Diaz
) in Shrek
. Desperate to lift their daughter's curse, King Harold (voiced by John Cleese
) and Queen Lillian (voiced by Julie Andrews
) meet with con artist Rumpelstiltskin (voiced by Walt Dohrn
), who requests becoming king of Far Far Away in exchange. Just before the king signs the contract, a page bursts in and announces that Princess Fiona has been saved. In the present, a disgruntled Rumpelstiltskin wishes Shrek was never born and seeks revenge.
Meanwhile, Shrek has grown tired of being a domesticated family man and celebrity among the local villagers; he even tires of his friends' visits. This leads him to yearn for the days when he felt like a "real ogre." He takes his family to Far Far Away to celebrate his children's first birthday with the villagers and his fairy tale friends. Many things at the party annoy Shrek: a little boy constantly asking for Shrek to roar; Donkey (voiced by Eddie Murphy
) licking the cake and the three little pigs eating it; his kids crying. After he lets out a roar of frustration, the entire crowd cheers. Puss in Boots (voiced by Antonio Banderas
) brings out a replacement cake, but Shrek smashes it and storms off.
Outside, Shrek rants to Fiona about how he was a "real ogre" and villagers feared him -- when he could do what he wanted when he wanted to -- before he rescued her. Fiona gives up trying to talk sense to Shrek and goes back inside. Rumpelstiltskin, hiding behind a garbage can, has witnessed the whole thing and plans his revenge.
Shrek wanders down the road and meets Rumpelstiltskin, who has faked a carriage accident. Shrek grudgingly helps him. Rumpelstiltskin in return offers to help Shrek by giving him a ride. Over "eyeball-tinis" and roast rat, Rumpelstiltskin convinces Shrek to sign the "Ogre for a Day" contract; in return all he has to give up is a day from his childhood he wouldn't remember being erased. Shrek agrees and signs the contract, and abruptly lands in a world where he is still feared by villagers. He enjoys causing mischief until he finds wanted posters for the ogress Fiona. He races back to his home, which he finds reclaimed by the tree and empty. Witches capture him and take him away in a caged carriage pulled by Donkey; Donkey doesn't know Shrek in this alternate world.
They reach Far Far Away, which has been turned into a town of poverty and misery, except for Rumpelstiltskin's luxurious castle, which uses ogres and Shrek's friends for slaves. The witches deliver Shrek to Rumpelstiltskin, who is celebrating his opulence with witches. He tells Shrek that the King and Queen signed over their kingdom to him to end Fiona's curse; instead they disappeared. Shrek realizes that the day he gave up was the day he was born. Rumpelstiltskin tells him that since he was never born, when the day ends so does Shrek; he never met Fiona and his kids don't exist.
Shrek angrily breaks free of his bonds and fights the witches, taking one of their brooms. He grabs Donkey and flies through the glass of a large window, pulling the giant jewel-encrusted ball that hangs from the ceiling (which gets damaged as it gets stuck in the window).
Safely in the forest, Shrek tries to convince Donkey to trust him but Donkey runs away in fear. Shrek finds an ogre child's doll and cries. Donkey has come back and asks Shrek why he's crying; Shrek tells him that he was tricked into signing Rumpelstiltskin's contract. Horrified, Donkey shows Shrek how to find the exit clause by folding the contract; Shrek re-folds it to reveal "true love's kiss" with the explanation: According to fairy-tale law, if not fully satisfied "true love's kiss will render this contract null and void."
Shrek remembers that he never rescued Fiona and they go to the castle where Fiona was being held captive; Fiona is gone, obviously after many years. Shrek presents Fiona's favor (handkerchief) to Donkey to help find her, but Donkey takes off after smelling something sweet. Donkey falls for a trap baited with waffles, and gets pulled underground. Shrek follows him and finds other ogres who have formed the resistance; the ogres demonstrate a war call by blowing their ears like trumpets. Fiona, in ogre form, comes out -- the leader of the resistance. They all hide when witches patrol overhead. Fiona tells them that they wont have to hide after tonight.
At his castle, Rumpelstiltskin plots with the witches how to catch Shrek so he won't be able to kiss Fiona and break the contract. Rumpelstiltskin decides to hire a bounty hunter.
Shrek and Donkey eavesdrop on Fiona, who is briefing her lieutenants on the counter-attack for Rumpelstiltskin's raid tonight. Shrek wonders how he will be able to kiss Fiona before sunrise. He goes to Fiona's tent and encounters Puss-in-Boots, who is fat and retired and who Fiona keeps as a pet. Fiona enters and Shrek tries to woo her with gifts, but she kicks him out.
The Pied Piper arrives at Rumpelstiltskin's castle and proves his expertise by making the witches dance. Rumpelstiltskin agrees to hire him.
The ogres eat Shrek's gifts and exclaim that these types of gifts won't work on Fiona. Donkey tells Shrek that Fiona only cares about the ogres' cause. Shrek seeks out Fiona and interrupts her practicing in her target room. They spar and become friends, but Fiona sends him out immediately afterwards.
Puss in Boots has eavesdropped on Shrek and Fiona, and informs Shrek that Fiona had possibly found her true love there with him. Shrek replies that he knows of her curse and recites it. Puss in Boots tells Shrek that he must tell Fiona something that only her true love would know.
Rumpelstiltskin's carriage and his witches leave the castle. The ogres leave their hideout and wait for the time to ambush. Fiona scouts ahead and Shrek follows her; he tells her that he knows about her curse. This distracts her and prevents her from giving the signal to attack. The ogres become impatient and attack the carriage and find it empty, and The Pied Piper emerges from the fake pet goose.
Fiona is suspicious of Shrek, but he tells her private things about her. The Pied piper plays his flute, breaking the moment and making them dance. They join all the other ogres, who are also dancing. Puss in Boots rescues Shrek and Fiona but they eventually wreck their wagon. Fiona leaves, but Shrek tries to stop her, even asking Puss in Boots for help, making Fiona suspicious. She kisses Shrek in anger, confusing Shrek when nothing changes. Fiona tells him that true love didn't rescue her from the tower; she saved herself. Fiona leaves, angry and bitter. Shrek realizes that Fiona doesn't love him.
The ogres are in cages in Rumpelstiltskin's castle. The Pied Piper informs Rumpelstiltskin that Shrek and Fiona are together. Rumpelstiltskin announces to the citizens of Far Far Away through the Magic Mirror (and all the other mirrors) that he is offering a reward for Shrek -- a contract to grant them all their wishes. Shrek, Donkey, and Puss in Boots hide as all the villagers storm out of town looking for Shrek. Shrek captures The Gingerbread Man (voiced by Conrad Vernon
), who explains the bounty to Shrek.
Shrek bursts into Rumpelstiltskin's castle, where everyone is trying to cash in on the bounty. He signs the contract in exchange for freeing the ogres. Shrek is happy that the ogres are freed and Fiona is safe, but Rumpelstiltskin shows him that she is also a prisoner, because she isnt "all ogre", and recites her curse.
Outside the castle, Donkey informs the ogres that they will bust into the castle the same way they busted out. Inside the castle, Rumpelstiltskin hoists up his new decorated ball, and celebrates by announcing he will execute Shrek and Fiona by Dragon in a grand ceremony. Donkey and Puss in Boots interrupt; then the ogres, who were hiding in the decorated ball, trumpet their ears and burst out. While the ogres battle the witches, Donkey tries unsuccessfully to woo Dragon. Shrek and Fiona team up to subdue Dragon and free themselves. The ogres defeat the witches, so Rumpelstiltskin attempts to leave on his goose, but Shrek and Fiona capture him.
Fiona exclaims that they make a good team, but Shrek begins to vanish due to the approaching sunrise. Before Shrek completely vanishes, he tells Fiona that they have kids, including Felicia. Fiona tells him that she always wanted to have a daughter named Felicia. He gives her the doll he found and tells her that the best part of the day was that he was able to fall in love with her again. Fiona has fallen in love with him too and kisses him before he completely vanishes.
The sun rises and Fiona is still an ogre -- true love's form. The kiss worked, and everything starts disappearing around Rumpelstiltskin. The contract has been nullified and Shrek is returned to his world just as he roars at the birthday party. Happy again with his family and friends, Shrek trumpets his ears, surprising Fiona. He tells her that she was the one who rescued him.
Shrek and his friends celebrate in the forest to "I'm a believer" by Smashmouth. Rumpelstiltskin is in a cage. Shrek is truly living happily forever after.