In a flashback, King Harold (John Cleese) and Queen Lillian (Julie Andrews) have lost hope of their daughter, Princess Fiona, being freed from her curse after so many years of her being at the Dragon’s Keep. The Princess would be a lovely woman by day and a hideous Ogre at night and can only be freed by a “True Love’s Kiss”.
Despite their deal with Fairy Godmother (who had indicated that only the kiss could break the curse), they go to Rumpelstiltskin for help. He has a magical contract that will seemingly lift the curse if they give him the Kingdom of Far Far Away.
They are about to sign the kingdom of Far Far Away over to “Rumpel” Rumpelstiltskin (Walt Dohrn), in exchange for lifting their daughter Princess Fiona’s (Cameron Diaz) curse. The deal is canceled at the last second when a messenger informs the king and queen that Fiona has been rescued by Shrek. Ever since, Rumpel has held a grudge against Shrek for ruining his plan.
An angry Rumpel laments his loss and wishes that Fiona’s rescuer Shrek (Mike Myers), was never born.
In the present time, Shrek has grown steadily weary of being a family man and celebrity among the villagers, leading him to long for when he was feared and had privacy. Shrek is a little tired of following the same routine day after day, endlessly, with no respite in sight. All his private moments are invaded by tour guides (who brings tourists to the swamp), or by Puss and Donkey (who also brings his hybrid Dragon-Donkey babies), who also stay for dinner. And if that is not enough, Fiona would constantly want Shrek to fix things around the house.
When he takes his family to a restaurant in Far Far Away to celebrate his children’s first birthday, an escalating series of mishaps further injure his ego. Donkey licks the cake, and the 3 little pigs eat it before the kids have a chance to cut it. A boy wants Shrek to perform for the audience by giving out his famous roar. The kids start crying as there is no cake, or even cupcakes or lollipops. Another cake is brought out, but Shrek is livid by seeing a happy Shrek face on the cake made in icing. This causes him to walk out in anger (after destroying the cake) and lashes out at Fiona. Shrek says that Fione would never understand as she is a Princess by heart and not a real Ogre. Fiona tries to remind that Shrek has 3 beautiful kids and a wife who loves him, and he should learn to appreciate that.
Having observed the outburst, Rumpel follows Shrek and arranges for him to appear to save his life. Inside Rumpel’s carriage, Shrek laments that he is no longer a “real ogre”. Pretending to thank Shrek for his good deed earlier, Rumpel offers Shrek a deal: A Day as a “real ogre” in exchange for a day from his childhood. Shrek signs the contract and is whisked away into an alternate reality.
Now feared by the villagers, Shrek takes the opportunity to cause some lighthearted mischief until he finds that Fiona is a fugitive, and his swamp home deserted and desolate. Knocked out and kidnapped by witches, he wakes up in a caged cart driven by Donkey (Eddie Murphy), who has never met him. Donkey tells Shrek he’s being taken to Rumpel, now the king of the derelict Far Far Away. The witches work for Rumpel and are tasked with finding all Ogres in the land and bringing them to him. The Ogres are enslaved in the castle and help power the heavy machinery that keeps the castle operational.
Rumpel reveals that he erased the day Shrek was born, meaning Shrek never existed in this alternate time-line. Consequently, Harold and Lillian were forced to sign the kingdom over to Rumpel. When the day ends, Shrek will no longer exist. He escapes Rumpel’s castle with Donkey. Initially terrified of Shrek, Donkey decides to trust him after seeing him cry over his erased history. Donkey helps Shrek find a hidden exit clause; the contract can be nullified by “true love’s kiss”.
They soon encounter a still-cursed Fiona leading an army of ogres in a resistance against Rumpel. Shrek discovers a lazy and overweight Puss in Boots (Antonio Banderas) being kept as Fiona’s pet. Shrek does everything he can to win over Fiona, but she is cynical and disillusioned about the power of true love after nobody rescued her, and she’s too busy preparing for an ambush on Rumpel. While sparring with Shrek, Fiona begins to take a liking to him, but they stop short of kissing. Puss encourages Shrek to continue pursuing Fiona.
During the ambush, the ogres are captured by the Pied Piper (Jeremy Steig), but Shrek and Fiona escape with the help of Puss and Donkey. Shrek insists that Fiona kiss him, assuring her that it will fix everything; she reluctantly obliges, but nothing happens since she’s not in love. When he hears that Rumpel is offering a wish to the one who brings him Shrek, Shrek turns himself in. Rumpel is forced to grant the wish to Shrek, and he uses it to free the other ogres. As Shrek is locked up, Rumpel reveals that Fiona had been captured and not released, since she is not “all ogre”. Donkey, Puss, and the freed ogres storm the castle; they capture Rumpel and defeat his witch army, while Shrek and Fiona take down Dragon.
As the sun rises, Shrek begins to fade from existence, but Fiona, having fallen in love with him, kisses him before he disappears. Seeing that she is still an ogre in the sunlight, Fiona realizes that her curse was broken and that she has assumed “love’s true form”. The alternate reality disintegrates, making everyone disappear, and Shrek finds himself transported back to the original time-line at the moment before he lost his temper at the party. Instead of lashing out, Shrek embraces his family and friends with a newfound appreciation for them.
Later, Shrek hosts a party in his swamp with his friends, family, and the other ogres, with an imprisoned Rumpel in attendance.