Sri Lanka 263 (Dhananjaya 69, Kamindu 64, Nissanka 64) and 94 for 1 (Nissanka 53*) need 125 more runs to beat England 325 and 156 (Smith 67, Kumara 4-21, Vishwa 3-40)
In a match as changeable as the weather in south London, Sri Lanka took control of the third and final Test against England on the third day at The Oval.
After an abject performance on the opening day when their bowlers failed to capitalise in prime conditions upon winning the toss, Sri Lanka had to watch Ollie Pope and Ben Duckett shine through the overhead gloom.
Then, two incisive passages of swing bowling - on a dark second day, then under bright skies on the third - had the tourists back in contention, but not before Jamie Smith had bludgeoned England out of dire trouble. Still, by the time bad light stopped play just before quarter to seven on Sunday evening, the match was Sri Lanka's to lose.
But it is the detail around those key moments that tell the story of where this Test sits heading into the final day.
Apart from Pope and Duckett, no England batter passed 20 in their first innings, as they were bowled out for an unremarkable 325. Despite Dhananjaya de Silva, Kamindu Mendis and Pathum Nissanka all passing fifty, no one pressed onto a big score that would have taken Sri Lanka past England, who led by 62 runs on first innings.
Then a struggling Dan Lawrence looked like top-scoring for England's second innings with his series-best 35 before Smith's brutal 67 off 50 balls made them the only home batters to pass 12 on the third day as Lahiru Kumara and Vishwa Fernando - with his devastating inswingers - kept them in check.
And so, when bad light brought another early close, Sri Lanka were 94 for 1 and needing 125 more for a consolation win. Chris Woakes' superb return catch removed Dimuth Karunaratne for just 8, but that was the only wicket to fall in Sri Lanka's free-scoring fourth innings.
Nissanka reached his second half-century of the match from just 42 balls by crunching a Josh Hull delivery to the rope wide of mid-off just before the light intervened, leaving him unbeaten on 53 with Kusal Mendis 30 not out.
Sri Lanka's bowlers, led by Vishwa, were making the ball move in what were by far the brightest conditions of the match so far, despite a couple of short interruptions for what amounted to sun-showers.
But then Smith pummelled 52 runs off the last 19 balls he faced, helping himself to 20 runs off one Milan Rathnayake over to lead England's second-innings recovery from 82 for 7 to 140 for 8.
By the time Olly Stone fell to give Kumara his fourth wicket and Asitha Fernando had Shoaib Bashir also caught behind by Nishan Madushka - standing in for the injured Dinesh Chandimal - England had stretched their advantage to 218.
Two early strikes had given Sri Lanka hope during a morning session extended because of bad weather over the first two days as Duckett and Pope fell cheaply.
Lawrence smashed Asitha for six over long-off and, two balls later, carved deftly through point for four. But, having bettered his previous series best by one run, he was brought undone by a Kumara delivery that moved away late and kissed the edge of the bat before landing in Chandimal's gloves.
Vishwa entered the attack in the 15th over and he struck third ball with a superb inswinging yorker that hit Joe Root on the boot directly in front.
Harry Brook had come under fire for his petulant reaction to Sri Lanka's successful bid to frustrate him by bowling outside off stump in the first innings. This time, he succumbed to another late inswinger which nailed the front pad with pin-point accuracy on leg stump in Vishwa's next over.
Kumara had Woakes caught behind for a six-ball duck but then Chandimal had to be helped off the field after diving stop a wayward Kumara delivery down the leg side to Gus Atkinson, hurting his lower back in the process. Atkinson was trapped lbw by Rathnayake, having faced 14 balls for his 1 before Smith got stuck in.
Earlier, Hull and Stone had preserved England's advantage after Sri Lanka resumed for the day on 211 for 5, trailing by 114. Hull made amends for dropping Dhananjaya on the second evening when he had the Sri Lanka skipper caught for 69 with his 11th ball of the day, an attempted pull looping off the top edge to deep backward square.
That sparked a procession of five wickets for 52 runs in 13.3 overs, Hull, Stone and Woakes sharing four of the five wickets to fall with Atkinson off the field nursing a thigh problem from which he recovered sufficiently to bowl in the fourth innings.