Tristan Stubbs and captain Temba Bavuma scored centuries on the third day as South Africa are now five wickets away from an imposing win over Sri Lanka in the first Test.

Resuming on 132-3, Stubbs and Bavuma built a 249-run fourth-wicket partnership for the hosts at Kingsmead with the former scoring his second Test ton in 183 balls before being bowled by Vishwa Fernando (2-64) for 122.

Bavuma departed for 113, trapped leg before wicket by Asitha Fernando (1-54) in the last ball before tea as the Proteas immediately declared at 366-5.

Sri Lanka, who capitulated to 42 all out in the first innings for their lowest-ever Test score, started poorly again as they chased a target of 516 set by their opponents.

Kagiso Rabada sent back opener Dimuth Karunaratne (four) early while Marco Jansen, who got 7-13 in the first innings, collected the wickets of Angelo Mathews (25) and Kamindu Mendis (10).

Rabada then bagged his second by dismissing Prabath Jayasuriya, leaving Sri Lanka at 103-5 at stumps and needing 413 runs, with Dinesh Chandimal (29 not out) and Dhananjaya de Silva (zero not out) at the crease when play resumes.

Data Debrief: Bavuma finally converts

South Africa skipper Bavuma needed 202 balls to bring up only his third century in the 60th Test match of his career.

The 34-year-old has developed a reputation for failing to convert his half-centuries into bigger scores, registering just 22 scores of 50 or more in Test cricket.

Bavuma scored his maiden Test ton (102*) against England in Cape Town in 2016, before his second (172) against West Indies in Johannesburg last year.