A try by JP Pietersen and 11 points from the boot of Elton Jantjies denied Ireland a first-ever series victory in South Africa.
After an early Elton Jantjies penalty, it was Ireland who scored the first try of the match as Luke Marshall barged over from close range following good retention through the phases by the Irish pack.
With Paddy Jackson and Jantjies swapping penalties, it was not until the final minute of the first half that South Africa retook the lead. Jantjies was the creator with his perfectly weighted kick allowing JP Pietersen to make a brilliant catch and score in the corner. Jantjies added a difficult conversion, and South Africa led 13-10 at the break.
Two more South African penalties -- one from Jantjies and another from Ruan Combrinck -- in the second half looked to have put the game away, but with 10 minutes remaining, Jackson reduced the deficit to six points with a penalty of his own.
Ireland pressed hard for the converted try they needed to snatch victory, including one 22-phase move that eventually ended in them conceding a penalty, and a late drive that ended with another penalty to South Africa with Ireland camped in the opposing 22.
While Ireland coach Joe Schmidt and his side will return home wondering what might have been after spurning a number of good opportunities, South Africa can now move on under new coach Allister Coetzee with optimism.
They led by three through Jantjies' penalty when the game encountered its big talking point.
On his first start, Ireland full-back Tiernan O'Halloran rose to claim Faf de Klerk's box-kick and found himself flying head over heels as his opposite number Willie le Roux crashed into his legs.
The Connacht star came crashing down on his upper body area and referee Glen Jackson went upstairs to consult with Rowan Kitt, who adjudged that O'Halloran had landed on his shoulder rather than his neck and the New Zealand official reached for his yellow card when he might have chosen red.
Given how Ireland's CJ Stander was sent off in the first Test, it was a huge call and O'Halloran needed a visit to the dressing room for a Head Injury Assessment as Matt Healy came on for his debut.
When O'Halloran returned after being cleared, Ireland were 7-3 in front through Marshall's try. The centre made up for some early errors by powering past Jantjies to score after an ambitious phase of attacking play involving Stuart Olding, Jack McGrath and Stander.
Paddy Jackson converted but then missed his first penalty attempt after Frans Malherbe went off his feet.
He slotted over another, easier opportunity from straight in front to make it 10-3 but Jantjies pulled a penalty back for the hosts when McGrath was penalised at scrum time.
Ireland should have gone further in front from a brilliant counter-attack after Iain Henderson dispossessed De Klerk. However, Marshall's final pass to Keith Earls was forward with the line at Munster winger's mercy.
And Ireland would rue that glorious missed chance when the Springboks struck for a try of their own on the brink of half-time. Siya Kolisi won a vital turnover on half-way and, after the men in white drove into Irish territory, Jantjies executed a perfect chip over Andrew Trimble's head for JP Pietersen to touch down.
Jantjies converted to give his side a 13-10 half-time lead and Ireland suffered a further blow as O'Halloran failed to re-appear after the interval, with Healy taking his place again.
Still, the Irish continued to play with positive intent and were inches away from scoring their second try only for De Klerk to reach up and intercept Jackson's final pass after some clever set-up play off good lineout ball.
Ireland's play was good to watch, but their error count was costing them and a Marshall knock-on was punished by the Springbok replacement props Steven Kitshoff and Julian Redelinghuys, who won a penalty in their first scrum which Combrinck nailed from inside his own half.
Jantjies added another penalty to stretch the lead to nine, but Ireland -- strengthened by their bench -- hit back immediately through Jackson's penalty and they began to believe they could make history.
Sean Cronin's fresh legs took him deep into South African territory, but a seemingly endless series of phases came to nothing when Rhys Ruddock went off his feet.
Still, Ireland came and brilliant foot-work from Olding took them close and they battered at the line repeatedly in a dramatic final phase. Finally, the ball reached Earls who had Healy outside him, but De Klerk rushed up and hit him hard. In piled the Springboks and the winger held on.
That proved the last action of the match as the stadium erupted and Ireland sunk to their knees.