Mahela Jayawardene hit an unbeaten 77 to get Sri Lanka within 90 runs of victory in the second cricket Test and a series sweep against South Africa.
Set 352 to win, the hosts ended the fourth day at 262 for five yesterday, leaving three sessions and five wickets to achieve the 90 runs required.
The Sri Lanka captain shared an unbroken 61-run stand for the sixth wicket with wicketkeeper-batsman Prasanna Jayawardene contributing 27 runs.
South Africa missed a chance to dismiss Mahela Jayawardene on two when he edged an Andrew Hall delivery to gully. But Herschelle Gibbs, one of the safest fielders in the team, failed to hold the chance.
It was a major reprieve for Sri Lanka. Jayawardene scored 374 in the first Test last week and shared a world record 624-run partnership with Kumar Sangakkara that laid the foundation for the innings victory. As long as he remains at the crease, Sri Lanka has a chance of winning.
Sri Lanka's highest run chase in Test cricket so far has been 326 against Zimbabwe at the Sinhalese Sports Club in 1997.
South Africa resumed yesterday at 257 for seven and added 54 before Mark Boucher's rearguard innings finished at 65.
Despite losing opening partner Upul Tharanga for a duck, veteran Sanath Jayasuriya started the chase aggressively for Sri Lanka with 73 from 74 balls.
The 37-year-old left-hander, who recently reversed his decision to retire from Test cricket, took the attack onto the South African bowlers reaching his 30th Test half-century in style by hoisting veteran paceman Shaun Pollock for a six that landed in the adjoining Air Force Camp.
He was particularly aggressive against Pollock and hit the bowlers first three balls of his third over for 4,4,6 and adding a quick 82 for the second wicket with Kumar Sangakkara.