The stylish Sangakkara became only the fourth player in test history to score seven successive half centuries as Sri Lanka threatened to seize control but he fell for 55 as England took two late wickets to stall the visitors' progress.
Having earlier polished off England's first innings for 365, Sri Lanka ended the day 106 runs ahead.
Sangakkara, who joined Everton Weekes, Shivnarine Chanderpaul and former England coach Andy Flower to score seven consecutive test half 50s, shared a 79-wicket third-wicket partnership with Mahela Jayawardene (55 not out).
Part-time spinner Moeen Ali took two late wickets, however.
Having reached tea on 99-2, nine runs behind, Sri Lanka needed little time moving into credit as Sangakkara continued his fluent play with a trademark drive to the boundary.
After watching Sri Lanka's bowlers get good movement on the flat Headingley pitch, England's attack toiled as they struggled to find the right line and length to trouble the Sri Lanka duo.
With England desperate to break the partnership, captain Alastair Cook turned to Moeen and the change of bowling brought about immediate rewards as he had Sangakkara trapped lbw for 55.
Within minutes Moeen had his second wicket, beating Lahiru Thirimanne with a ball that spun past the batsman's tentative prod to remove his bails for a second duck of the match.
"It was just nice to contribute to the side to get us back into the game," Moeen said. "They were playing really well at the time so to contribute in that way was great.
"I was just trying to bowl as straight as I could to him (Sangakkara) and just bowl a dot ball really. He was playing so well and he'd taken me down a couple of times."
England continued to press but the determined Jayawardene reached his 48th test match 50.
Sri Lanka negotiated the final 45 minutes of the day without any more setbacks, but only after surviving reviews from both Ali and Liam Plunkett who himself had taken two wickets in the afternoon session.
"If we can have a good session early tomorrow we've seen on this wicket you can lose wickets in clusters so hopefully that can happen tomorrow," Moeen said.
"Get a couple before the new ball and then rip through their tail."
Resuming the day on 320 for six, England were torn apart by the Sri Lankan bowling attack with captain Mathews taking test-best figures of 4-44 and Shaminda Eranga taking 4-93.
Sri Lanka needed just one hour of the morning session to bowl the hosts out as England added just 45 runs to their overnight score, losing their last eight wickets for 87 runs.
In response James Anderson, Stuart Broad and Chris Jordan struggled to trouble the Sri Lanka openers, prompting Cook to bring Liam Plunkett into the attack.
The Yorkshire-seamer, who claimed test-best figures of 5-64 in the first innings, quickly accounted for Kaushal Silva (13).
Sangakkara made a streaky 79 in the first innings but the elegant left-hander was quickly into his stride with three sumptuous drives to the cover boundary.
At the other end Karunaratne (45) quietly accumulated runs but he became Plunkett's second victim shortly before tea, gloving the aggressive bowler to Prior down the leg side.
Sangakkara and Jayawardene threatened to carry the game away from England but Moeen's late wickets restored parity with the match poised intriguingly heading into day four.
The first test of the two-match series ended in a draw at Lord's last week.
- Sports & Recreation
- Sri Lanka
- Mahela Jayawardene