The 17-point margin at the end didn't reflect the intensity of a match that where the Scots will regret failing to take multiple opportunities they created.
Scotland were also forced to play 20 minutes of the opening half with 14 men when Scott Cummings was given a yellow card which was harshly upgraded to red.
Scotland's points came from the boot of Finn Russell with Makazole Mapimpi (2), Thomas du Toit and Jasper Wiese scoring tries for the visitors. Handre Pollard kicked the other points.
Scotland head coach Gregor Townsend tells BBC Scotland: "A lot of pride in the performance. I thought it was a brilliant Test match - hugely physical.
"We matched South Africa for a lot of the game and we were down to 14 for 20 minutes. I thought the team looked mentally strong.
"A couple of skill errors cost us and we didn't get the rub of the green with decisions, clearly. South Africa then showed their power in the last 10 minutes.
"That effort in the second half was outstanding. To open up their defence at times and match their physicality. We will be frustrated because there were a couple of opportunities out there.
"We played one of our best games of the last few years today, and we pushed the world champions very close. There are areas we have to improve, but some of the defence today was world class. The effort that went in is all we want from a Scotland team.
"We know we could have executed better and had decisions go against us, but they deserved to win, South Africa."
Jack Dempsey was forced off with a shoulder injury but Townsend said it was too early for a full diagnosis.
"Jack got a real bang on his shoulder," Townsend said.
"It's not looking good at the moment but we need to see what happens with the scan. But I don't think he'll be available in the next few days or next week - let's hope it's not too serious."