Number 11 Nuwan Pradeep survived five dramatic balls from Stuart Broad to help Sri Lanka avoid defeat after James Anderson ripped through the visitors to almost force an England win in the first Test at Lord's.
Sri Lanka had half an eye on an outrageous attempt to win the match and made steady progress in their second innings, losing opener Dimuth Karunaratne for 16 before lunch.
Sangakkara and Kaushal Silva put on 98 for the second wicket before the latter fell for 57, his second half-century of the match.
The diminutive Silva held his nerve in the face of some well directed bouncers from Liam Plunkett to add to his first-innings 63, before gloving Chris Jordan through to keeper Matt Prior down the leg side.
Jayawardene also came in for a short-pitched examination from Plunkett but eventually went to Anderson as he feathered an edge through to Prior, leaving the tourists 266 behind at tea with seven wickets left.
With 34 overs left in the test, Sri Lanka were looking towards Sangakkara to provide a solid base, but Anderson had other ideas.
After passing 50 for the sixth straight innings, Sangakkara chopped the ball onto his stumps from Anderson in the third over after the interval.
England up tempo
Thirimanne, who failed to look at ease in his two appearances at the crease, edged Anderson to Jordan in the slips four balls later to raise home hopes of an amazing end to the rest.
The visitors were teetering at 170 for five, but captain Mathews and wicketkeeper Prasanna Jayawardene, ruled out of the second Test due to bruising in his hand, resisted the fired-up English attack for just over 20 overs, taking a number of blows to the body in the process.
They put on 24 runs in 121 balls before Prasanna went lbw to Jordan and then Nuwan Kulasekara fell in similar fashion to Broad soon afterwards.
Mathews later edged to Cook in the slips to give Anderson his fourth wicket of a remarkable effort and the Lord's crowd suddenly believed a famous victory could be in sight.
Broad dismissed Rangana Herath with the first ball of the final over but Pradeep survived the remarkable final five balls.
While they could not quite get the job done, the performance will give hope to an England side looking to move on from the controversial end to Kevin Pietersen's international career and the 5-0 Ashes thrashing in Australia.