Scotland suffered their first defeat of the Autumn Nations Series as South Africa ran out 30-15 winners at Murrayfield.
South Africa dominated the opening stages but Finn Russell scored a penalty to get Scotland ahead after Duhan van der Merwe was brought down during a scintillating break.
Elton Janjies' penalty and a try from Makazole Mapimpi got the Springboks back ahead.
But Murrayfield erupted on 35 minutes as Stuart Hogg touched down and Russell converted to see Scotland lead the world champions 10-8.
Gregor Townsend's men could've been even further ahead at the interval but Russell sent a penalty wide of the posts.
South Africa really went up a gear after the break, going ahead 15-10 as Mapimpi went over. Janties added another three points through a penalty.
Scotland's task was made harder as Jamie Ritchie gave away his third penalty of the match, which saw Janties bag more points to make it 10-21.
Despite not having much possession, Scotland made their touches count as Stuart Hogg scored a try. Russell again pulled wide from the conversion.
The usually reliable Handre Pollard missed a penalty for the visitors as he knocked it wide. But he made no mistake from a similar position moments later to put his side 24-15 ahead.
South Africa effectively ended Scotland's hopes of a comeback as they capitalised on yet another penalty. Frans Steyn hammered home from 48 metres.
The result was all but sealed when a Bok scrum in the Scotland 22 ended in a penalty for South Africa. Pollard leisurely slotted it home.
After outmuscling Scotland in the second half, Rassie Erasmus' side ran out comfortable 30-15 winners.