Sri Lanka captain Angelo Mathews and paceman Dhammika Prasad pushed England to the brink of defeat as the home side, set 350 to win, slumped to 57 for five on the fourth day of the second and final Test.
England trailed by only 106 runs and seemed to have the upper hand at the start of the day but Mathews and Mahela Jayawardene wrested away the initiative by scoring freely in the opening hour.
After the first couple of days we never thought we would be in this position
Mathews stroked a magnificent 160 to help Sri Lanka power their way to a second-innings total of 457 at Headingley after resuming on 214 for four.
James Anderson lifted England when he tempted Jayawardene (79) to offer an edge to keeper Matt Prior before Liam Plunkett accounted for Dinesh Chandimal (seven) and Prasad (duck) in consecutive balls.
Another Plunkett double
Paceman Plunkett claimed two in two for the second time in the game as he added figures of four for 112 to his first-innings haul of five for 64.
Prasad then produced a fiery spell of fast bowling to rip the heart out of England's batting by removing skipper Alastair Cook (16) and Gary Ballance (duck), in consecutive balls, Sam Robson (24) and Ian Bell (eight).
"After the first couple of days we never thought we would be in this position," Mathews told reporters as Sri Lanka closed in on their first series victory in England.
"The job is only half done. We need to take five wickets and will stick to our basics."
The first test at Lord's ended in a draw.