Sri Lanka 157 157 (Perera 60, Nortje 6-56, Mulder 3-25) and 150 for 4 (Karunaratne 91*, Ngidi 3-26) lead South Africa 302 (Elgar 127, van der Dussen 67, V Fernando 5-101) by five runs
Johannesburg: Dean Elgar hit his 13th century before Sri Lanka fought back on day two of the second Test against South Africa at the Wanderers, Johannesburg on Monday.
The experienced opener, unbeaten on 92 after the opening day on Sunday, went on to score 127 (163 balls, 22 fours) before his team stuttered and stumbled their way to 302 all out - an innings lead of 145.
Sri Lanka skipper Dimuth Karunaratne's unbeaten 91 off 116 balls (17 fours) then helped the Islanders to close the day on 150 for four.
Karunaratne's knock gave the visitors a lead of five at the end of the second day, a far more promising position than they may have foreseen on Sunday when the South Africans closed day one on a commanding 148 for one having dismissed Sri Lanka for 157 in the first essay.
On Day two, after good initial progress by Elgar and Rassie van der Dussen (67 off 127 balls, 12 fours), the Proteas lost their way badly by losing their last nine wickets for a poor 84.
The overnight pair extended their second-wicket partnership to 184, before both finally fell with the score on 218, the latter completing his fourth career half-century during his innings.
Things then unravelled badly for the home side as the key middle-order trio if Faf du Plessis (8), Quinton de Kock (10), and Temba Bavuma (19) fell cheaply.
Debutant Vishwa Fernando was the chief destroyer as he bagged a five-for, ending with figures of five for 101, with the hosts, bowled out in 75.4 overs.
South Africa's spearhead Lungi Ngidi, who bounced back from his first innings blank with three for 26, then landed an early blow to the islanders when he cleaned up Kusal Perera for one to leave the Sri Lankans on one for one early on.
But skipper Karunaratne and Lahiru Thirimanne (31) knuckled down during a partnership of 85 for the second wicket to get the innings back on track.
Ngidi, however, set them back badly with two wickets in two balls and Anrich Nortje (1/41) struck 17 runs later to suddenly leave the tourists in a big hole at 109 for four.
The captain then found another partner willing to fight in the form of Niroshan Dickwella (18) as they closed out the day with their side in the lead.