Graeme Swann took two wickets in a dramatic penultimate over to raise England's hopes of a series-levelling victory in the second Test against Sri Lanka.
England had started the day solidly but went 43.3 overs without success in the evening as their nemesis Mahela Jayawardene and Thilan Samaraweera put on 90 for the fifth wicket.
Then, with the tourists fatigued by heat and humidity and facing a tricky chase on day five, Swann bowled Samaraweera and Suraj Randiv in the space of three balls.
His ecstatic celebrations as the stumps parted on each occasion showed just how important this could be for England - who need victory to draw level with Sri Lanka at 1-1 and preserve their world number one status.
At the close the hosts were 218 for six - a fragile lead of 33 - but with Jayawardene on 55 not out and in sight of his third century in a remarkable series.
England, who had time for just one over last night, were hoping to knock nightwatchman Dhammika Prasad over early but he quickly became a bigger problem than regular opener Lahiru Thirimanne.
Swann came on after six overs and soon had Thirimanne in strife. Matt Prior missed a simple stumping but it did not cost England as the opener guided James Anderson to slip for 11.
Tillakaratne Dilshan arrived next and immediately went into defensive mode - something of a rarity for the flashy all-rounder.
Prasad continued to ride his luck, edging Swann just past Prior for four and then being dropped badly by Steven Finn two balls later.
His frustrating cameo was finally ended on 34 when he lifted a Finn bouncer down Tim Bresnan's throat at fine leg.
Kumar Sangakkara's woeful series almost continued when Finn drew a thick edge off the new man, but he hung on and lunch came with the score 84 for two.
Sangakkara, though, was far from his best - prodding and fending at Anderson at the start of the second session.
Samit Patel was getting good turn but lost his length as he gave Sri Lanka 12 runs in two overs to chip away at the lead.
Swann was summoned to replace the slow left-armer and struck with his first ball.
He turned one in to Dilshan's bat and pad and appealed as soon as Anderson accepted a looping catch at slip.
Umpire Bruce Oxenford upheld the shout but Dilshan immediately called for DRS.
There was no conclusive proof either way, meaning the dismissal was upheld to Dilshan's clear chagrin.
The referral system was in use again three balls later when Oxenford rejected a big lbw appeal from Swann against Sangakkara.
This time technology frustrated England, reprieving the batsman by the smallest of margins.
But there was no doubt when Prior gathered a thin edge off Swann to send Sangakkara back for 21 and leave the hosts 60 behind at 125 for four.
That brought Sri Lanka's most diligent pairing, Jayawardene and Samaraweera, together and they calmly added 14 before tea.
Eight balls after the restart Jayawardene offered up a rare chance, miscuing Patel in the direction of mid-on.
Bresnan was the fielder but could not cling on one-handed and, instead of heading back for 20, Jayawardene picked up his second boundary.
It had the feel of a crucial moment.
He pulled Bresnan for a third four, this a much more commanding stroke, to bring up the 150 as England began to show signs of weariness.
Their advantage slipped into the teens as Jayawardene swept Swann for four and when Samaraweera eased Patel for a single, Sri Lanka took the lead.
As if to celebrate moving into credit Samaraweera plundered successive boundaries off Kevin Pietersen and drove Swann for a magnificent straight four.
Jayawardene's fifty arrived with his 125th ball as England continued to search unsuccessfully for a fifth wicket.
Their best hope now lay with the new ball and, after nine overs of seam, it was Swann who made the breakthrough in the last over of the day.
He turned one sharply at Samaraweera, who was shocked by the spin and ended up dislodging a bail as he ran the ball off the face of the bat.
Swann summoned up one more piece of magic to bowl Randiv through the gate, giving England some much-needed momentum to use on the fifth morning.
Scoreboard at end of play
Sri Lanka 1st Innings 275, England 1st Innings 460, Sri Lanka 2nd Innings, (Overnight 4-0)
Dhammika Prasad c Bresnan b Finn 34
Lahiru Thirimanne c Strauss b Anderson 11
Tillakaratne Dilshan c Anderson b Swann 35
Kumar Sangakkara c Prior b Swann 21
Mahela Jayawardene not out 55
Thilan Samaraweera b Swann 47
Suraj Randiv b Swann 0
Anjelo Mathews not out 3
Extras: (4b, 6lb, 2w) 12
TOTAL: (for 6 wickets) 218
Overs: 91. Batting time: 383 minutes.
Fall of wickets: 1-23, 2-64, 3-104, 4-125, 5-215, 6-215.
Still to bat: Prasanna Jayawardene, Rangana Herath, Suranga Lakmal.
Bowling: James Anderson 16-6-27-1, Steven Finn 15-1-30-1 (1w), Graeme Swann 26-1-82-4, Tim Bresnan 11-5-14-0 (1w), Samit Patel 19-6-37-0, Kevin Pietersen 4-0-18-0.
Toss: Sri Lanka.
Series: Sri Lanka leads two-match series 1-0.
Umpires: Asad Rauf, Pakistan, and Bruce Oxenford, Australia .
TV umpire: Rod Tucker, Australia. Match referee: Javagal Srinath, India.