Angelo Mathews scored a brilliant century and Dhammika Prasad took four wickets to leave England struggling after being set 350 to win the second and final Test against Sri Lanka at Headingley.

With excellent support from Rangana Herath, who made 48, Mathews scored 160 to guide Sri Lanka to 457 in their second innings.

Prasad then removed England's top four batsmen as the home side lurched to the close on 57 for five, nightwatchman Liam Plunkett gifting his wicket to Herath in the final over of the day.

And it might have been even worse for the home side as before that, both Plunkett (0) and Joe Root (6 not out) were given out caught behind only to be able to call on the review system to remain at the crease.

Nevertheless, they face a huge battle on the final day as Sri Lanka look for a first series win in England since they won a one-off Test in 1998.

Resuming on 214 for four, Sri Lanka made steady progress in the morning session with Mahela Jayawardene and Mathews extending their fifth-wicket partnership to 94 before Jayawardene was caught by Matthew Prior off James Anderson for 79 in 168 balls.

Plunkett then had Dinesh Chandimal (7) and Prasad (0) dismissed cheaply to leave Sri Lanka at 277 for seven.

What followed was a counter-attack that deflated England as they failed to break the stand between Mathews and Herath.

They batted for well more than 30 overs and after a few rash strokes early on, Herath settled down, enabling Mathews to rotate the strike cleverly, often hitting boundaries from the final balls of the innings and completing his second century of the series.

Herath deserved a half-century but fell when he was sent back by Mathews and run out by Root having faced 82 balls.

Mathews, who made 160 in 249 balls with 25 fours and a six, finally fell when he was caught by Moeen Ali off Anderson, who then bowled Nuwan Pradeep for a duck to end the innings.

Plunkett finished with four for 112, Anderson three for 91 and Ali two for 74.

Sri Lanka then showed England, who for all Mathews' brilliance, bowled poorly, how to bowl on a Headingley pitch, bowling a consistently full length mixed in with the odd bouncer.

England had made 39 before Prasad struck with a short ball that Alastair Cook (16) contrived to edge onto his stumps as he tried to pull.

One ball later, Ballance was trapped in front and England had only just got 50 on the board when Sam Robson drove at Prasad and was caught by Jayawardene at slip for 24.

That was Jayawardene's 197th catch in Tests, taking him past Ricky Ponting on the all-time list, but he should have grabbed a 198th soon after, giving Plunkett a reprieve.

Not that it mattered much as after Prasad bowled Ian Bell for eight, and both Plunkett and Root immediately reviewed Billy Bowden's decisions to give them out caught behind, Plunkett inexplicably drove at the second ball of the final over, bowled by Herath, and was caught by Pradeep at extra cover.

Prasad finished the day with four for 15 and Herath had one for 13. Five more wickets on the final day and Sri Lanka should make history.

England would also make history if they chased down 350 - more than they have ever done before - but their target now, is to save the game, and even that looks to be beyond them.