The two South Africans fought it out at Randpark Golf Club in Johannesburg. Oosthuizen, the overnight leader, produced a hole-in-one on No. 8 to send the crowd wild. Grace responded with four straight birdies, starting on No. 11, to go 9 under on the last day and finish 21 under overall.
''That was remarkable,'' Grace said. ''I played flawless golf and I can't remember the last time the putter was that hot.
''This is the one I really wanted. This means so much to any South African, winning on home soil. The guys get so behind you and it's such an emotional feeling.''
Grace picked up eight birdies and an eagle on the day, and just one bogey, and ended up pulling away from Oosthuizen, who closed with a 3-under 68 to finish 18 under.
Oosthuizen aced the par-3 eighth but had only one other birdie in his final round.
It was the 31-year-old Grace's ninth European Tour title and first victory at the South African Open. He won the Nedbank Golf Challenge at Sun City in 2017, meaning he's now won his home country's two most prestigious tournaments. That success in Sun City three years ago was his last win on the tour.
The victory propelled Grace into the lead in the Race to Dubai. He has a win and a third place in his two tournaments on the tour so far this season. It also secured Grace a place at this year's British Open.
Oosthuizen already had a place at the Open after winning the title in 2010.
Marcus Armitage (69) finished third in Johannesburg on 16 under after a birdie on his final hole. Jack Senior (67) and Jaco Ahlers (69) were in a tie for fourth. Armitage and Ahlers also qualified for the British Open at Royal St. George's.
More AP sports: https://apnews.com/apf-sports and https://twitter.com/AP-Sports