Second Test, Colombo (PSS), day two (stumps): South Africa 361 & 6-0 v Sri Lanka 321
Jayawardene kick-started Sri Lanka's recovery
Two century stands from Sri Lanka's lower middle order helped the hosts recover from 98-5 to close to within 46 runs of South Africa in Colombo.
The morning belonged to Makhaya Ntini, who took 4-33 to leave the hosts reeling in reply to the Proteas' 361.
But Chamara Kapugedera and Prasanna Jawardene combined in a partnership of 105, before Chaminda Vaas and Farveez Maharoof shared a 117-run stand.
That helped take Sri Lanka to 321 all out, South Africa ending play on 6-0.
We need to keep the South Africans down in the second innings
And home coach Tom Moody was delighted with his side's battling effort, saying: "We are back in the game.
"We were a bit down at one stage but I was not surprised at how well the lower order fought.
"Chamara is a real talent and it was good to see Prasanna stick it out. Then Vaasy played like he can and Maharoof improved as he went along.
"We need to keep the South Africans down in the second innings and, if we can do that, there is a lot to play for over the next three days."
The hosts had to recover after a morning session when Ntini struck twice with the new ball before returning ahead of lunch for two more wickets in the space of three balls.
The key scalp was Sanath Jayasuriya, caught at second slip just before the break for 47 after slashing at a wide one.
The paceman had earlier struck at either end of his opening spell as Upul Tharanga top-edged an attempted pull and Kumar Sangakkara clipped a rising delivery off his hips to short midwicket.
Sri Lanka briefly recovered with Jayasuriya and skipper Mahela Jayawardene adding 31.
But, first, Steyn removed the veteran opener and then Ntini's return saw Dilshan surprised by some extra bounce and he chopped onto his leg stump.
Sri Lanka emerged from lunch in determined mood and Kapugedera and Jayawardene were both content to play their shots.
Ntini took two wickets in three balls just before lunch
Kapugedera smashed nine boundaries and two sixes in his 77-ball innings, while Jayawardene hit six fours and a six in his seventh Test.
However, both departed in the space of six deliveries late in the post-lunch session to hand the advantage back to South Africa.
Kapugedera was bowled trying to sweep Nicky Boje and Jayawardene bowled by a fast Steyn delivery.
That brought Chaminda Vaas and Farveez Maharoof to the crease, and the pair surpassed the previous pair's stand.
Adopting a more pedestrian approach, the pair hung around for the majority of the final session, Maharoof scoring 56 from 110 balls and improving batsman Vaas 64 from 130.
They eventually fell to Steyn, who ended with five wickets for a less-than-economical 82, and Sri Lanka were bowled out 40 runs behind.
Herschelle Gibbs and Andrew Hall then saw out the final two overs of the day without incident to keep South Africa's noses just in front.