England were wrestling with an Angelo Mathews-inspired Sri Lanka as the second Test headed for a nerve-shredding conclusion on day four in Kandy.
Having slumped to 26 for three in pursuit of 301, Mathews' unbeaten 87 underpinned a defiant comeback that saw the hosts take tea just 82 short of victory on 219 for five.
Jack Leach's triple strike with the new ball had seemed to put his side on course for a series-clinching victory but Keaton Jennings did just as much for the cause, pulling off cricketing miracles at short-leg.
Having claimed a stunning, tumbling one-handed catch to see off Dhananjaya de Silva, his bravery and brilliance under the helmet also accounted for the assured Dimuth Karunaratne just after lunch.
Faced with a full-blooded sweep, he anticipated the stroke and instinctively thrust a hand out to parry the ball into Ben Foakes' gloves.
Ordinarily that might have been enough to persuade Sri Lanka it was not their day but Mathews, dropped by Ben Stokes on seven from a taxing chance at slip, played a defiant hand from number five.
With the pitch slowing under foot and the ball softening in the hand, England were looking for inspiration in the evening session to avoid going 1-1 heading to Colombo.
Having started the job of grinding England down alongside Karunarate (57), Mathews brushed off Jennings' jaw-dropping intervention to go again alongside Roshen Silva.
Those stands were worth 77 and 73, with Mathews the steady centre-point of both.
He reached his half-century in 75 balls, a relatively brisk effort given he hit only three boundaries in that time.
Instead he watched the ball diligently, played it late where he could and made the most of gaps in the field.
Moeen Ali eventually made England's second breakthrough of the afternoon session, Roshen (37) held at slip after a slight nick onto his front pad, but Niroshan Dickwella scored a run-a-ball 23 before the break to keep the pressure up.
Leach had earlier opened the bowling in place of Sam Curran, who was off the field receiving treatment on a side strain.
He started superbly, Kaushal Silva well stumped by Foakes after the hard ball offered sizeable turn and bounce, De Silva undone by Jennings' reflex grab and Kusal Mendis lbw on the sweep.