South Africa won the series by two matches to nil, with one match finishing in a rain-affected draw.
The left-handed Elgar made 60 not out as South Africa reached a victory target of 124 shortly before lunch.
It was tough going for South Africa at the start of the day after they resumed on nine for one.
Fast bowler Jerome Taylor and left-arm spinner Suleiman Benn did not concede a run until Elgar pulled Taylor for four after 26 minutes and off the 45th ball of the day.
The tall Benn was particularly difficult to score off, getting turn and bounce from a wearing pitch, with Faf du Plessis completely tied down.
Benn, who bowled Alviro Petersen with the last ball of the fourth day, did not give up a run until Du Plessis took a single off the fifth ball of his sixth over.
Du Plessis struggled to 14 off 69 balls before a ball from Benn kicked viciously and took the shoulder of his bat for Jermaine Blackwood to take a catch running back from gully.
Benn took two for 24 in an unbroken spell of 17 overs.
Elgar, who spoiled Benn’s figures slightly by hitting him for six, went to his fifty off 86 balls with six fours and a six.
The scoring rate accelerated when captain Hashim Amla joined Elgar in an unbeaten partnership of 73 off 91 balls. Amla made 38 not out.
South Africa won the first Test in Centurion by an innings and 220 runs. The second match in Port Elizabeth was drawn after more than two days of playing time was lost to rain.
The sides start a three-match Twenty20 international series at Newlands on Friday, to be followed by five one-day internationals. (AFP)