Casey, who last won a tournament at the 2007 Abu Dhabi event, had three bogeys on the back nine to finish at 21-under 267.
I have missed winning for the last two years, so this one is very special, said Casey, who captured his ninth title on the European Tour.
Oosthuizen, who started the day seven shots behind Casey, tied the days best round at 64. Sergio Garcia, who finished tied for eighth at 272, also shot a 64.
Kaymer (67) rolled in a 25-foot eagle putt on the par-5 18th to finish tied for second.
Anthony Wall (67) was fourth at 270, and another stroke back in a tie for fifth was Padraig Harrington (66), Northern Ireland teenager Rory McIlroy (65) and Johan Edfors (67).
Casey, who had the lead heading into the final round, started with a pair of birdies Sunday and soon stretched his lead to six shots with birdies at Nos. 6, 8 and 10. But bogeys on the 11th, 13th and 14th, and birdies by Oosthuizen on the 15th and 18th, made it close.
I was really getting nervous over the back nine, Casey said. I never once looked at the leaderboard throughout the round, but I was aware where Martin was, and I was sure someone must have done better than him.
And then I saw Oosthuizens smiling face on the big screen near the 18th and I knew he had done something special. When I finally looked at the leaderboard after reaching the 18th green, I heaved a sigh of relief that I still had two putts to win the tournament.