Shrek and Fiona return from their honeymoon to find they have been invited by Fiona’s parents to a royal ball to celebrate their marriage. Shrek refuses to go at first, but Fiona talks him into it, and along with Donkey, they travel to the kingdom of Far Far Away. They meet Fiona’s parents, King Harold and Queen Lillian, who are surprised to see their daughter as an ogre, with Harold particularly repulsed. At dinner, Shrek and Harold get into a heated argument over how Shrek and Fiona will raise their family, and Fiona, disgusted at Shrek and Harold’s behavior, locks herself away in her room that evening. Shrek worries that he has lost his true love, particularly after finding her childhood diary and reading that she was once infatuated with Prince Charming.
Harold is reprimanded by the Fairy Godmother and Charming, her son, by reminding Harold for violating a promise that Charming would be able to marry Fiona, and request that he find a manner to get rid of Shrek. Harold arranges for Shrek and Donkey to join him on a fictitious hunting trip, which actually is a trap to lure them into the hands of an assassin, Puss in Boots. However, Puss is unable to defeat Shrek and, revealing that he was paid by Harold, requests to come along and make amends. The three sneak into the Fairy Godmother’s potion factory and steal a “Happily Ever After” potion that Shrek thinks will restore Fiona’s love for him.
Shrek and Donkey both drink the potion and fall into a deep sleep, awakening the next morning to discover its effects: Shrek is now a handsome human, while Donkey has turned into an elegant white stallion. In order to make the change permanent, Shrek must kiss Fiona by midnight. He, Donkey, and Puss return to the castle to discover that the potion has transformed Fiona back into her former human self as well. However, the Fairy Godmother, having discovered the potion’s theft, intercepts Shrek and sends Charming to pose as him and win her love. At the Fairy Godmother’s urging, Shrek leaves the castle, thinking that the best way to make Fiona happy is to let her go.
To ensure that Fiona falls in love with Charming, the Fairy Godmother gives Harold a love potion to put into Fiona’s tea. This exchange is overheard by Shrek, Donkey, and Puss, who are soon arrested by the royal guards and thrown into a dungeon. While the royal ball begins, several of Shrek’s friends band together to free the trio, creating a monster-sized gingerbread man, which breaks through the castle’s defences so Shrek can prevent Charming from kissing Fiona. He is too late to stop them; instead of falling in love with Charming, though, Fiona knocks him out with a headbutt. Harold reveals that he never gave Fiona the love potion, whereupon the now enraged Fairy Godmother attacks Shrek. In the ensuing melee, Harold sacrifices himself to save Shrek; Harold’s armour ricochets the Fairy Godmother’s spell which disintegrates her into bubbles; it also returns Harold to his true form as the Frog Prince. He had used the Happily Ever After potion years before in order to marry Lillian, but she tells him that she loves him regardless of his appearance.
As the clock strikes midnight, Shrek and Fiona let the potion’s effects wear off and they revert to their ogre forms, while Donkey changes back to his natural form as well. Harold gives his blessing to the marriage and apologizes for his earlier behavior, and the party resumes. After the party, the Dragon, who had previously romanced Donkey, arrives and reveals that they now have several dragon-donkey hybrid babies.