The 38-year-old Hansen finished at 15-under-par 269 for his third European Tour win and first since the 2007 BMW PGA Championship.
McLardy, one of three third-round leaders, shot a 68 and finished alone in second place at 14-under 270. Playing in the final threesome, he was unable to make a birdie over his last six holes.
David Drysdale had a 69 to take third place at 13-under 271 and Charl Schwartzel posted a 70 to share fourth place with Tyrone Van Aswegen (68) and Danny Willett (68) at 12-under 272. Drysdale and Schwartzel had shared the 54-hole lead with McLardy.
Ten players finished within five strokes of Hansen, but Retief Goosen was not among them. The two-time U.S. Open winner, just a shot off the lead overnight, stumbled to a 74 and dropped into a tie for 23rd place at 7-under 277.
Hansen, playing in the second-to-last group, began making his move on the front nine at Royal Johannesburg and Kensington.
He birdied five holes, including four in a row ending at the ninth, to make the turn in 31 shots. He birdied the seventh and eighth holes for the second day in a row.
Hansen slowed down after that, making two pars to start the back nine before dropping his only shot of the final round with a bogey at the 12th. Five pars later, he was tied with McLardy at 14 under par heading to the 18th.
He reached the green in two shots at the 551-yard closing hole, landing his ball 25 feet from the cup. Hansen missed his eagle putt, but rolled in a 3-footer for birdie to take the clubhouse lead.
Then, he waited.
McLardy ' struggling to get anything going down the stretch after he made three straight birdies to start the back nine ' still had a chance to tie Hansen.
But, playing for his first European Tour victory, he pulled his shot into the trees at the 18th and walked off with his sixth par in a row, clinching the win for Hansen.
'I think it means a lot to win obviously ' because that's of course what we're here for,' said Hansen, who was eight shots off the lead after the first round.
'Especially after the first day, where the first two holes I started double bogey-bogey and [thought] 'What is this?' But I turned that round around and got off to a flying start the second day. I couldn't keep it going, but that sort of helped me put things into perspective thinking about the next day.'
Further back, Richard Sterne, who won the previous two European Tour events and entered this week as the defending champion, finished strong. He carded a 68 and tied for 12th place at 9-under 275.