Prince Charming vows that he will become King of Far, Far Away and avenge the death of his mother, the Fairy Godmother. Meanwhile, King Harold is dying and his ogre son-in-law Shrek and daughter Princess Fiona are to succeed him. Shrek's attempts at trying to serve as the Regent during the King's medical leave end in disaster, and insists that an ogre as king is a bad idea and that there must be someone else to rule the kingdom. Before dying, Harold tells Shrek of another heir: his nephew, Arthur Pendragon. Prince Charming goes to the Poison Apple tavern and persuades fairy tale villains to fight for their "happily ever after" by appealing to the defeats given in their stories.
Shrek, Donkey and Puss in Boots set out to retrieve Arthur; as they are sailing away, Fiona yells to Shrek that she is pregnant. The trio journey to Worcestershire Academy, an elite magical boarding school, where they discover Arthur or "Artie" is a scrawny 16-year-old underachiever picked on by everyone. At the school pep rally, Shrek tells Artie he is going to be king of Far Far Away. Artie is excited until Donkey and Puss inadvertently frighten him by discussing the responsibilities of being king. Artie tries taking control of the ship and crashes it on a remote island, where they meet Artie's retired wizard teacher, Merlin.
Meanwhile, Charming and the other villains attack the castle, but Wolfie, Pinocchio, Gingy, the Three Little Pigs and the Blind Mice stall them long enough for Fiona and her mother Queen Lilian to escape along with Snow White, Rapunzel, Cinderella, Sleeping Beauty and Doris the Ugly Stepsister. One of the Pigs accidentally blurts out that Shrek has gone to retrieve Arthur, and Prince Charming sends Captain Hook and his pirates to track down Shrek. The ladies are put in a tower when Rapunzel betrays them because she loves Charming.
Captain Hook and his pirates track Shrek and his friends to Merlin's island, where they attempt to capture Shrek alive and defeat the others. Shrek and Artie defeat the villains, and Hook mentions Charming and the takeover of Far Far Away. Concerned for his wife and future children, Shrek urges Artie to return to Worcestershire. Instead, Artie cons Merlin into using his magic to send them to Far Far Away. The spell works, but accidentally causes Puss and Donkey to switch bodies. They find Pinocchio and learn that Charming plans to defeat Shrek in a play. Charming's men arrive, but Artie tricks the knights into not taking them into custody and they break into the castle during rehearsals for the play. Caught in Charming's dressing room, the four are taken captive.
Charming prepares to defeat Artie, believing he is the next king. To save Artie's life, Shrek tells Charming that Artie was a pawn to take his place as King of Far Far Away. Charming believes Shrek and allows Artie to leave. Donkey and Puss are imprisoned with Fiona and the ladies, where Fiona grows frustrated with their lack of initiative. Queen Lilian smashes the stone wall of the prison by head butting the walls. While the princesses launch a rescue mission for Shrek, Donkey and Puss free Gingy, Pinocchio, the wolf and pigs, Dragon and Donkey's children. They encounter Artie, and Puss and Donkey explain that Shrek lied to save him.
By nightfall, Charming stages a musical in front of the kingdom. Just as Charming is about to defeat Shrek, Fiona, along with Puss, Donkey, the princesses and the fairy tale characters confront the villains. Artie convinces the villains that just because they are being treated like losers does not mean that they have to be losers.
Infuriated, Charming lunges at Artie with his sword, but Shrek blocks the blow, so Charming attacks him instead. Shrek, who seems fatally injured, informs Charming that he missed and that the Prince needs to keep looking for his own happily ever after. As Shrek pushes him aside, Dragon knocks Rapunzel's tower on Charming presumably killing him. Artie is then crowned king, and takes the throne. While the kingdom celebrates, Merlin restores Puss and Donkey to their proper bodies, accidentally switching their tails temporarily. Shrek returns home to the swamp with Fiona, becoming the parents of ogre babies.
- Knockout, Puffer, Dolphy, Rachel, Mighty Joe, Daylight, Jenny, Pete, Kevin, Alberto, Morley, Blitzer, Blythe Baxter, Zoe Trent, Pepper Clark, Penny Ling, Vinnie Terrio, Sunil Nevla, Minka Mark, Russell Ferguson, Gail Trent, Mitzi, Buttercream Sunday, Sugar Sprinkles, Nutmeg Dash, Captain Cuddles, Youngmee Song, Sue Patterson, Jasper Jones, Team Griffin/Eeveelution, The Griffin Family, Vinny Griffin, Glenn Quagmire, Cleveland Brown, Joe Swanson, Little Bear, Duck, Cat, Owl, Hen, Emily, Lucy, Doug Funnie, Skeeter Valentine, Roger Smith, Bender Bending Rodríguez, Minerva Mink, Master Shake, Meatwad, Frylock, Pazu, Sheeta, The Crystal Prep Girls, Wubbzy, Widget, Walden, Daizy, The Young Six (Silverstream, Smolder, Ocellus, Sandbar, Gallus, and Yona), Natsu Dragneel, Lucy Heartfilia, Gray Fullbuster, Erza Scarlet, Wendy Marvell, Happy, Carla, Tempest Shadow, Grubber, Songbird Serenade, Capper, Captain Celaeno, Princess Skystar, Queen Novo, Hiro, Charlie, Sunset Shimmer, Skarloey, Rheneas, Sir Handel, Peter Sam, Rusty, Duncan, Victor, Kevin, Duke, Lady, Trevor, Duck, Donald and Douglas, Oliver, Toad, Spencer, Arthur, Murdoch, Rosie, Stanley, Annie and Clarabel, Henrietta, Paxton, Mavis, Jack, Alfie, BoCo, Daisy, Ryan, Skiff, Mike, Rex, Bert, Zecora, Princess Ember, Gabby, Babs Seed, Coloratura, Moon Dancer, Minuette, Lemon Hearts, Twinkleshine, Barrington, Northumberland, Pugwash, Stewiacke, Owen, Rebecca, Constance, Sir Topham Hatt, Princess Celestia, Princess Luna, and Barret Barricade guest star in this film.
- After our heroes are transported back to Far Far Away, Peter and Zoe's bodies will be switched.
- The storyline continues in Thomas and Twilight Sparkle's Adventures of Shrek: Forever After.
- Prince Charming's revenge/Royal problems
- King Harold's funeral
- Charming rallies the villains
- The quest begins/Shrek's nightmare
- Worcestershire Academy/Finding Arthur
- The Baby shower/Charming's attack
- Crash landing/Meeting Mr. Merlin
- Shrek and Arthur make up
- Fiona and the royals captured/Rapunzel's true colors
- The attack/Mr. Merlin's magic
- Returning to Far Far Away
- Shrek captured/thrown in prison
- The play begins/breaking back into Far Far Away
- The final fight/Charming's defeat
- Arthur becomes king/Shrek and Fiona's happily ever after
- Royal Pain
- Live and Let Die
- Joker & the Thief
- That's What Friends are For
- Pokémon: Lucario and the Mystery of Mew - Weavile Party Meeting! (when Hook and some of the villains attack the group)
- 9 Crimes
- Immigrant Song
- Losing Streak
- Best Days of My Life (for the end credits)