The superb Jonathan Sexton kicked Ireland into a 6-0 lead before Handre Pollard replied before the break.
Rhys Ruddock's try straight after half-time helped increase Ireland's lead to 13-3 before Marcell Coetzee's score cut the margin to three points.
However, two more Sexton penalties and Tommy Bowe's try put the game out of sight before JP Pietersen's late score.
The Springboks went into the game hot favourites after beating New Zealand a month ago but found themselves unable to match Ireland's remarkable resolve.
Ruddock was a late inclusion in the Ireland team after original selection Chris Henry was ruled out by illness.
Ireland had heroes all their pitch with prop Jack McGrath brave in the scrum and at the breakdown but there was no doubting that Sexton was deserving of his man-of-the-match honour.
The Irish fly-half conclusively won his duel with emerging Springboks fly-half Handre Pollard as the home side effectively targeted both South Africa half-backs.
Springboks scrum-half Francois Hougaard endured a nightmare evening as South Africa's backs moves were largely confined to runs from lively full-back Willie le Roux.
Joe Schmidt's players also showed a ruthlessness in the closing 15 minutes after replacement hooker's Adriaan Strauss's sin-binning was followed by Bowe's match-clinching try.
With Sexton orchestrating, the Irish effectively mixed a kicking and running game in the early stages and the fly-half kicked the opening points in the eighth minute after McGrath had out-duelled Jannie du Plessis in a scrum.
Ireland, minus regular hooker Rory Best, struggled in a couple of early line-outs and had an escape in the 13th minute as Hougaard's fumble at the base of a ruck just short of the line allowed McGrath to hack to safety.
Sexton's 24th-minute penalty increased Ireland's lead before the home scrum began to creak for the first time.
Media playback is not supported on this device
South Africa's scrum dominance forced two kickable penalties in three minutes but their decision to chase tries from line-outs backfired on both occasions as the Irish defence held firm.
Pollard finally opened South Africa's account before the break to cut the margin to three and the visitors must have remained confident as they trudged into the dressing-rooms.
However, they were rocked within two minutes of the restart by Ruddock's crucial try.
Young Irish centre Robbie Henshaw's superb kick had forced Le Roux to concede a line-out deep in Springboks territory and Ruddock burst through to score after Devin Toner had soared to win Sean Cronin's throw.
Sexton's conversion increased Ireland's lead to 13-3 but there was still some 36 minutes of action left.
The visitors looked right back in the contest on 57 minutes as Coetzee barged his way over after the option of turning down an easy three points finally bore fruit.
Pollard's conversion cut the margin to three but crucially Ireland doubled their advantage within six minutes as Sexton punished Duane Vermeulen's high tackle on Jamie Heaslip.
Bakkies Botha was introduced width 15 minutes remaining but the South Africans were then handed a hammer blow as replacement hooker Strauss was yellow carded for his high tackle on Rob Kearney.
With their numerical advantage, the Irish produced intense pressure in the 70th minute and it yielded Sexton's fourth penalty of the match as there was to be no repeat of his crucial late miss against the All Blacks 12 months ago.
Ireland's remarkable victory was secured within two minutes as Murray's perfectly weighted chip in behind the defence was grabbed by Bowe before he dived over the line.
The magnificent Sexton landed the conversion before he was hauled ashore and his replacement Ian Madigan then got in on the scoring act with another penalty before an Aviva Stadium attendance that appeared stunned by the magnitude of the home victory.
Pietersen ran in South African's second try in the closing seconds but was it was little consolation for the visitors.
TEAMS
Ireland: Rob Kearney; Tommy Bowe, Jared Payne, Robbie Henshaw, Simon Zebo; Jonathan Sexton, Conor Murray; Jack McGrath, Sean Cronin, Mike Ross; Devin Toner, Paul O'Connell; Peter O'Mahony, Rhys Ruddock, Jamie Heaslip.
Replacements: Richardt Strauss for Cronin 60 mins, Dave Kilcoyne for McGrath 73, Rodney Ah You for Ross 73, Mike McCarthy for Toner 73, Tommy O'Donnell for O'Mahony 71, Eoin Reddan for Payne 78, Ian Madigan for Sexton 75, Felix Jones for Kearney 75.
South Africa: Willie le Roux; Cornal Hendricks, Jan Serfontein, Jean de Villiers (capt), Bryan Habana; Handre Pollard, Francois Hougaard; Tendai Mtawarira, Bismarck du Plessis, Jannie du Plessis; Eben Etzebeth, Victor Matfield; Marcell Coetzee, Teboho Mohoje, Duane Vermeulen.
Replacements: Adriaan Strauss for Bismarck du Plessis 51, Trevor Nyakane for Mtawarira 66, Coenie Oosthuizen for Jannie du Plessis 71, Bakkies Botha for Etzebeth 65, Schalk Burger for Mohoje 47, Cobus Reinach for Hougaard 57, Pat Lambie for for Pollard 66, JP Pietersen for Hendricks 50
Referee: Romain Poite (France)
Under-strength Ireland produced a display of discipline and invention to stun the in-form Springboks in Dublin.