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.
ga('create', 'UA-72310761-1', 'auto', {'name': 'pacontentapi'});
ga('pacontentapi.set', 'referrer', location.origin);
ga('pacontentapi.set', 'dimension1', 'By Rory Dollard, Press Association Sport Cricket Correspondent, Kandy');
ga('pacontentapi.set', 'dimension2', '1178151b-6acc-4de5-baf7-5026013ba86f');
ga('pacontentapi.set', 'dimension3', 'paservice:sport,paservice:sport:uk,paservice:sport:world');
ga('pacontentapi.set', 'dimension6', 'story');
ga('pacontentapi.set', 'dimension7', 'composite');
ga('pacontentapi.set', 'dimension8', null);
ga('pacontentapi.set', 'dimension9', 'sport:cricket');
ga('pacontentapi.send', 'pageview', { 'location': location.href, 'page': (location.pathname + location.search + location.hash), 'title': 'Angelo Mathews frustrates England as second Test heads for thrilling climax'});