England were left needing 36 fifth-day runs to win a gripping first Test against Sri Lanka, after being dragged into an exhausting battle of wills in Galle.
The tourists have been firm favourites ever since skittling their opponents for just 135 on the first afternoon and, while they remain well positioned to close out victory, they were challenged all the way on Sunday.
First Sri Lanka turned a 286-run deficit into a lead of 73, an outstanding effort of belligerent batsmanship, then they set the hares running by reducing Joe Root's side to 14 for three as nerves frayed and shadows lengthened.
The umpires called time with England on 38 for three, with Jonny Bairstow and debutant Dan Lawrence at the crease having settled the situation down in failing light. After single-figure dismissals for Dom Sibley, Zak Crawley and captain Root, senselessly run out in the growing chaos, it was a slender but crucial stand.
Sri Lanka had finally been bowled out for 359, keeping England sweating in seething heat for almost 137 overs, with Jack Leach claiming a hard-earned five for 122.
The left-arm spinner was playing just his third first-class match since November 2019, a period that saw him battle life-threatening sepsis in New Zealand and further illness and injury at home and abroad. Having taken his time to find rhythm he wheeled his way through just under 42 overs and saved his team a bigger chase by taking the final four wickets to fall.
Lahiru Thirimanne also turned in a memorable performance, with his 111 representing his first Test hundred in more than seven years.
Sri Lanka had served notice of their willingness to scrap by reaching 156 for two on the third evening – already vastly improved on their previous attempt.
England got off to a good start as they attempted to unpick that hard work, Dom Bess dismissing nightwatchman Lasith Embuldeniya for a duck in the second over of the day via a gentle prod to short cover.
Bess was unable to follow his success with a spell of sustained pressure and dropped short enough to guide Thirimanne from his overnight score of 76 to a long, long-awaited hundred.
On four separate occasions he was able to rock on to his heels and cut the off-spinner for four, the last of which brought up his landmark on the same ground he had last celebrated one in 2013.
Leach was not as costly as Bess but his early efforts were still too timid to move the game forward as he would do later in the day. Instead England had to hang in and hope the new ball would help them out of a hole.
It did just that, with Sam Curran finding a little movement from the hard Kookaburra and clipping the inside edge of Thirimanne's bat. It briefly looked as if the ball would canon back into the stumps, but Buttler watched it sail over the top and claimed a smart catch.
What followed between lunch and tea was an extended game of cat and mouse, during which just 60 runs came in 29 overs. Stuart Broad paved the way for the slow going, strangling the rate by allowing just one run from a precise five-over spell, and Bess came to the fore again when he picked up Dinesh Chandimal's outside edge to part a stand of 48 with Angelo Mathews.
Mathews (71) was chipping away carefully, though, and when he and Niroshan Dickwella erased the last of the English advantage things were getting tense. The rising unease was settled somewhat with a double strike from the spinners, Bess drawing a flat-footed prod from Dickwella for his eighth of the match and Leach effectively yorking Dasun Shanaka.
Leach completed England's long slog in the evening, hoovering up Wanindu Hasaranga and then benefitting from Buttler's first Test stumping – a smart piece of opportunism ending 28 Tests and 53 innings of waiting as a wicketkeeper. Mathews was last out as he looked to farm the strike but succeeded only in feeding Root.
A winning mark of 74 was bigger than the tourists might have hoped for, but still left them heavy favourites. That tag became lighter by the moment, though, as Sri Lanka proved to be hard-punching underdogs.
Sibley's apparent vulnerability to spin was first to surface, gifting Embuldeniya his off stump as he misjudged the arm ball. The uncertainty was contagious, Crawley surviving a bad drop by Dickwella before perishing at gully off the nagging left-armer.
Root, fresh from a majestic 228 in the first innings, was back on centre stage much earlier than he would have liked and back in the pavilion with even more regrettable haste.
Called through for a rash single by Bairstow, he was slow to get going, quick to collide with Perera and well short of his ground as the keeper threw down the stumps.
Bairstow and Lawrence played out for the close and will resume on the final morning, where a compelling comeback should finally be extinguished.