Prince Charming, disgraced after the events of the previous film and the death of his mother, the Fairy Godmother, vows revenge against Shrek and schemes to claim the throne of Far Far Away. Determined to rally support, he visits the Poison Apple tavern and persuades a group of fairy tale villains to join his cause, promising them their “happily ever afters.” Together, they plan to overthrow the kingdom.
Meanwhile, Shrek and Princess Fiona are named successors to the throne as King Harold’s health declines. Shrek, reluctant and ill-suited for royal duties, struggles as the acting regent. On his deathbed, Harold reveals the existence of another heir: Arthur “Artie” Pendragon, Fiona’s cousin.
After Harold’s funeral, Shrek, along with Donkey and Puss in Boots, sets sail to find Artie. Before departing, Fiona reveals she is pregnant, much to Shrek’s dismay as he doubts his ability to be a father. Their journey leads them to Worcestershire Academy, an elite boarding school, where they discover that Artie is an awkward and insecure 16-year-old. Shrek informs Artie of his destiny as the future king, which initially excites the young man. However, Donkey and Puss inadvertently terrify him with exaggerated tales of royal responsibilities, causing Artie to panic and attempt to commandeer the ship back to the school. In the ensuing chaos, the ship crashes on a remote island where they encounter Merlin, Artie’s eccentric retired teacher. Merlin helps Shrek and Artie bond, building trust between them.
Back at the castle, Fiona and Queen Lillian host a baby shower, only to be ambushed by Charming and his villainous allies. While Fiona and the other princesses are imprisoned, their friends-including Gingy, Pinocchio, the Big Bad Wolf, and the Three Little Pigs-stall the villains long enough for Fiona and Lillian to plot their escape. Meanwhile, Captain Hook and his pirates are sent to capture Shrek and Artie.
On the island, Shrek narrowly evades Hook, who reveals Charming’s coup. Determined to protect Artie, Shrek insists they return to Worcestershire, but Artie convinces Merlin to magically transport them to Far Far Away. The spell works, but with a side effect: Donkey and Puss accidentally switch bodies.
Once in the kingdom, Shrek learns that Charming plans to execute him in a theatrical spectacle. While attempting to rescue him, Shrek and his friends are captured. To protect Artie, Shrek lies to Charming, claiming he only brought Artie as a pawn to avoid being king himself. Convinced, Charming spares Artie and dismisses him.
Fiona, frustrated by the other princesses’ passivity, takes charge. With Queen Lillian’s help, they break out of the dungeon and rally their friends. Meanwhile, Puss and Donkey persuade a disheartened Artie to return, explaining Shrek’s lie was meant to protect him.
Charming’s theatrical execution of Shrek begins, but the audience openly mocks him, favoring Shrek. Just as Charming is about to deliver the fatal blow, Fiona, the princesses, and their allies storm the stage. Though initially overwhelmed, the tide turns when Artie arrives and delivers an impassioned speech to the villains, urging them to embrace their potential and follow their dreams instead of resorting to evil. Inspired, the villains abandon Charming’s cause and reconcile with the kingdom.
Enraged and unwilling to surrender, Charming lunges at Artie with a sword. Shrek intervenes, seemingly struck, but the blow misses. Dragon topples the stage tower onto Charming, ending his reign of terror.
With Charming defeated, Artie is crowned king of Far Far Away, uniting the kingdom in celebration. Merlin reverses Donkey and Puss’s body swap, and the group returns to the swamp, where Shrek and Fiona embrace their new roles as parents to triplets, navigating the chaos of parenthood with help from their friends.