The latest film in DreamWorks's animated comedy series nets £8.9 million over the weekend to knock Russell Brand's Get Him To The Greek from the chart summit.
Killers and Sex And The City 2 fall to numbers three and four respectively, while Bollywood movie I Hate Luv Stories bows at five. French rom-com Heartbreaker is the only other new release to chart in the top ten, landing at number six.
Elsewhere, Woody Allen's latest film Whatever Works climbs a place in its second weekend in cinemas to claim the number ten spot.
The UK box office top ten in full: 1. (-) Shrek Forever After - £8,955,554 2. (1) Get Him To The Greek - £1,048,898 3. (2) Killers - £274,768 4. (3) Sex And The City 2 - £212,501 5. (-) I Hate Luv Stories - £202,907 6. (-) Heartbreaker - £119,742 7. (4) Prince Of Persia: The Sands Of Time - £92,682 8. (6) Death At A Funeral - £68,609 9. (7) The Collector - £65,042 10. (11) Whatever Works - £49,321