Gary Ballance's maiden Test century put England back in control of their own destiny against Sri Lanka at Lord's.
The hosts lost their first five wickets in only 15 overs and stumbled to 121 for six, but a determined Ballance (104no) and number eight Chris Jordan - in their second and debut Tests respectively - rescued a stumps total of 267 for eight, and lead of 389, on day four.
After bowling Sri Lanka out for 453, despite a century from visiting captain Angelo Mathews (102), the task apparently facing England was to balance risk and reward with the bat in this first Investec Test.
On a pitch which has offered the bowlers little throughout, however, Shaminda Eranga (three for 63) and Rangana Herath (four for 95) had other ideas.
The seamer took three for three in a fine spell from the nursery end, and the slow left-armer then bagged two wickets in three balls as England faltered from 46 for none.
Number three Ballance refused to join the collapse, but until Jordan came in, there was no lasting support for the left-hander.
England had faltered to a decidedly vulnerable position but Jordan played beautifully in a crucial stand of 78 and Ballance would not be moved.
There was some outstanding timing and placement from Jordan - and although fewer memorable strokes from Ballance, until he showed truer colours by producing several as he neared three figures - his concentration and defensive technique served England especially well.
His near three-hour 50 took 130 balls, a highly-effective counter to the wobble which had otherwise taken hold - and then he needed only another 54 for his second 50, reaching his hundred in the final over of the day with a hoick for six over midwicket off Herath to add to his 12 fours.
First-change Eranga made short work of both openers, Alastair Cook edging behind as he attempted a flat-footed drive and debutant Sam Robson bowled off an inside edge through the gate by a ball which held its line up the slope.
Ian Bell soon went to Eranga in near action replay, although trying to play a more expansive shot.
First-innings double-centurion Joe Root made only 15, Herath turning one past his defence to hit the back pad.
Moeen Ali responded by going up the pitch first ball to hit Herath over mid on for four, only to be bowled by the next delivery - a beauty that spun up the slope.
Matt Prior endured an uncanny repeat from the first innings, again reprieved on nought by 'umpire's call' after a review when Herath thought he had hit him in line lbw - this time from the third rather than second ball he faced.
Unlike on Thursday, however - when Prior went on to make 86 - he was unable to take significant advantage, cutting Nuwan Kulasekara straight to gully soon after tea.
The likelihood was that England would be bowled out well before the close.
But by the time Jordan was done, squirting a catch to mid off from a leading edge at Herath, Cook could again contemplate the timing of his second declaration in the match and prospects of bowling Sri Lanka out in a day or slightly less.
Mathews' 172-ball hundred, to add to Kumar Sangakkara's memorable 147, had earlier helped to keep the hosts out in the field for another 75 minutes on a cloudy morning.
Mathews received enough support from the tail against England's pace attack to move from an overnight 79 to three figures.
Herath faced 14 balls from Stuart Broad, almost all short, before he found himself having to deal with James Anderson (three for 93) for the first time.
Anderson needed only one shot at the left-hander too, full and fast enough to knock out middle-stump.
Mathews went to his century, in his first Test innings in this country, smashing a full-toss over extra cover for his 12th four from the final ball of an Anderson over - after England had brought up the field to keep number 10 Eranga on strike at the other end.
Mathews lasted only one more delivery, Liam Plunkett immediately seeing him off when he missed a full-length ball and was lbw - before number 11 Nuwan Pradeep was felled by a bouncer from Jordan (three for 102) and smacked the stumps with his bat as he fell to be last out hit-wicket.
England therefore had their chance to begin second-innings consolidation, a task ultimately accomplished if not by conventional method.