Four penalties from Handre Pollard, playing his 50th Test, gave the Springboks a 12-3 half-time advantage as the struggling Lions were made to pay for indiscipline.
Luke Cowan-Dickie crashed over early in the second half, but a somewhat contentious Faf de Klerk try extended the world champion's lead.
Dan Biggar took his tally from the tee to 14 points with a couple of penalties to put Warren Gatland’s side in front for the first time with 18 minutes to play and Owen Farrell put it five points up late on.
The Springboks had two second-half tries ruled out and could not provide a late twist, with Pollard missing a penalty and conversion attempt.
The tackles flew in and high kicks galore were sent up in a frantic start and the Springboks struck a psychological blow when they had the better of the first scrum.
Pollard put the world champion in front with a 13th-minute penalty and he doubled the advantage to punish Tom Curry for a late hit on live-wire five-eighth Faf de Klerk.
Biggar got the Lions on the board soon after with a great strike from long range midway through a breathless first half, but another two clean strikes from the tee from Pollard made Gatland's side pay for yet more indiscipline with relentless South Africa winning the battle.
The Lions struggled at the lineout and Biggar pulled a penalty wide, while Elliot Daly was just short with a shot at goal from inside his own half before Willie le Roux kept his side nine points in front late in the first half with a great tackle on a charging Robbie Henshaw.
South Africa came out after the break with a new front row but was pushed back by an unstoppable driving maul only three minutes into the second half, with Cowan-Dickie touching down and Biggar adding the extras.
Le Roux had a try ruled out for offside moments later, but television match official (TMO) Marius Jonker was in the spotlight again when he saw no issue with a score awarded to De Klerk, which the Lions thought should have been overturned for a Pieter-Steph du Toit knock-on.
Biggar's penalty made it a one-point game and the five-eighth put the Lions in front with another clean strike from the tee.
Pollard had failed to convert De Klerk’s try and he missed a penalty after Hamish Watson was fortunate to escape without a card for a tackle on Le Roux.
There was further drama when Damian de Allende’s try was chalked off for offside with eight minutes to go and the Lions clung on to take a series lead following a late Farrell penalty.