Shrek, a grouchy, mean, selfish green ogre that has always enjoyed living in peaceful solitude in his swamp, finds his life disrupted when numerous fairytale beings, including Pinocchio, the Three Little Pigs, and Donkey, are forced into the swamp by order of the obsessive, perfectionistic, fairy-tale despising Lord Farquaad. Shrek leaves the swamp to ask Farquaad for the return of his privacy, with Donkey happily tagging along. Meanwhile, Farquaad tortures the Gingerbread Man into revealing the whereabouts of the remaining fairytale creatures until his guards rush in with an object Farquaad has been searching for: the Magic Mirror. The Mirror tells him that Farquaad can only become a real king by marrying a princess (completely disregarding his original question regarding if his kingdom was the fairest of them all). The Mirror gives him three princesses to choose from (in a parody of The Dating Game): Cinderella, Snow White, and Princess Fiona. Farquaad chooses Fiona and silences the Mirror before he can mention "the little thing that happens at night" (which is later revealed to be a curse). Shrek and Donkey arrive at Farquaad's palace in Duloc, where they find themselves in the midst of a tournament. The winner will have the "privilege" of attempting to rescue Fiona from a castle surrounded by lava and protected by a fire-breathing dragon so that Farquaad may marry her. Shrek (with some help from Donkey) easily beats the other knights in a fashion that resembles a wrestling match and Farquaad agrees to remove the fairytale creatures from the swamp if Shrek rescues Fiona.
Shrek and Donkey travel to the castle and split up to find Fiona. Donkey encounters the dragon and sweet-talks the beast to save himself before discovering that the dragon is female. Dragon takes a liking to Donkey and carries him to her chambers. When Shrek finds Fiona, she is appalled at his lack of romanticism. As they are leaving, Shrek manages to save Donkey, caught in Dragon's tender clutches, and causing her to become irate, chasing Shrek, Fiona, and Donkey out of the castle. At first, Fiona is thrilled to be rescued but quickly becomes disappointed when Shrek takes his helmet off and she realises that he is an ogre. The three make their return journey to Farquaad's palace, with Shrek and Fiona finding they have more in common with each other along the way, and falling in love. However, at night, Fiona refuses to camp with them, taking shelter in a nearby cave until morning. Shrek and Donkey stay awake and watch the stars while Shrek informs Donkey that he plans to build a 10 foot wall around his swamp when he returns. When Donkey persistently asks Shrek why he is doing this, Shrek sadly confesses to him that everyone judges him before they know him; therefore, he feels he is better off alone, despite Donkey's admittance that he did not immediately judge him when they first met.
The next night, Fiona takes shelter in a nearby windmill. When Donkey hears strange noises coming from the windmill, he finds Fiona has turned into an ogress. Fiona explains she was cursed as a child and turns into an ogress every night, which is why she was locked away in the castle, and that only a kiss from her true love will return her to her "love's true form". Shrek, about to confess his feelings for Fiona, overhears part of their conversation, and is heartbroken as he misinterprets her disgust at her transformation into an "ugly beast" as being disgusted with him. Fiona makes Donkey promise not to tell Shrek about the spell, vowing to do it herself, but when the next morning comes, Shrek has brought Lord Farquaad to Fiona. The two return to the castle, while a hurt Shrek returns to the now-vacated swamp, not long after breaking off his friendship with Donkey, out of anger.
Shrek finds that, despite his privacy, he is miserable and misses Fiona. Furious at Shrek for what he did, Donkey comes to the swamp where Shrek reveals that he overheard Donkey and Fiona's conversation. Donkey keeps his promise to Fiona and tells Shrek that she was talking about someone else. He then tells him that Fiona will be getting married shortly, urging Shrek into action to gain Fiona's true love. They are able to travel to Duloc quickly, thanks to Dragon, who had escaped her confines and followed Donkey. They interrupt the wedding before Farquaad can kiss Fiona, but not before the sun sets, which causes Fiona to turn into an ogress in front of everyone. While her transformation causes Shrek to fully understand what he overheard at the windmill, Farquaad, disgusted over the change, orders Shrek killed and Fiona imprisoned, but Shrek whistles for Dragon, who bursts in and devours Farquaad. Shrek and Fiona admit their love for each other and share a kiss; Fiona is bathed in light as her curse is broken, but is surprised to find that she has remained an ogress, as she thought she was supposed to become beautiful, to which Shrek replies that she is beautiful. The two of them get married in the swamp and depart on their honeymoon while the rest celebrate by singing "I'm a Believer".