Shrek (Mike Myers) successfully escapes from the Dragon with Fiona (Cameron Diaz) and also defeats Rumpelstiltskin (Walt Dohrn) and his army of Wicked Witches. At the same time, he and Fiona acknowledge and proclaim their love for each other.
However, dawn breaks and Shrek starts to vanish in front of everyone, according to what the nefarious contract dictated.
Fiona gets to kiss Shrek before he completely fades away. But then, she herself doesn't turn into a human, which means that she managed to break the curse of Rumpelstiltskin's contract.
In consequence, this alternate universe is undone and we are brought back to the actual timeline of the birthday party from earlier, in which Shrek had snapped and roared ferociously in front of everyone.
Upon realizing everything he came to love and appreciate has returned back to normal, he is joyous; he kisses Fiona and embraces all the rest of his family and friends, and of course...
THEY ALL LIVE... HAPPILY... EVER... AFTER!!
Before the credits roll, we see the entire gang (including the Ogres' Army) celebrating Shrek's triplets' birthday party at the swamp grounds -with Rumpelstiltskin shown as a prisoner and the large goose exploding at Fiona's loud singing-, and everyone is seen doing "mud angels" at the end of this sequence.