England were left chasing 74 to win the first Test against Sri Lanka after a five-wicket haul from Jack Leach finally drew the home side's spirited resistance to an end on day four in Galle.
Lahiru Thirmanne's first Test century in more than seven years set the tone for the belligerent second innings of 359, during which his side erased England's lofty 286-run lead and then built a modest target of their own.
And while the tourists remain on course for a big victory – any other result at this stage would now require a huge collapse with the finish line in sight – they were dragged into an exhausting battle of wills to establish their final position.
Sri Lanka kept them in the field for a total of 136.5 overs, refusing at any stage to indulge the kind of lackadaisical shot selection that saw them rolled for just 135 on day one, a collective debacle that looks set to cost them the match.
Leach's stint totalled just under 42 overs and he walked away with five for 122 after picking up the last four wickets.
He settled well to his task as the day went on, having previously admitted an interrupted year had left him short of match practice coming into the game.
Fellow spinner Dom Bess also left himself room for improvement but his haul of three for 100 left him with eight for the match.
Angelo Mathews was last man out for 71, having defied England for nearly six hours, guiding Leach to Joe Root at slip. Jos Buttler had earlier made a key contribution of his own, showing an opportunist's instincts with the gloves to earn a desperately tight stumping and remove Dilruwan Perera.
It was Buttler's first such dismissal in Test cricket, a lengthy wait comprising 28 Tests and 53 innings as wicketkeeper.