Until Moeen Ali put England back on track with two wickets in three balls midway through the final session, Sri Lanka had hauled themselves from a position in which they were in danger of heavy defeat to one where, with the prospect of a deteriorating pitch, and England to bat last, even of winning the match. That possibility still remains. At one stage, on Saturday evening, England already had a first innings advantage, Sam Robson was well past celebrating his maiden Test century and was continuing on his unobtrusive way, even stepping from his crease to hit only the sixth six of his firstclass career. There were eight first innings wickets still in hand. Everything was rosy.

Sri Lanka’s spirited response was to take those wickets at a further cost of only 87 runs. A combination of Shaminda Eranga’s enthusiastic pace, Angelo Mathews’ steadiness, and some ordinary batting on a surface that for no discernible reason had started to make a little mischief, ran through the England order – Matt Prior alone holding things together with an unbeaten 27.

If England had been heading for an unassailable lead at one stage, then 365 all out, a lead of only 108, was poor. Worse was to follow: Chris Jordan, in possession of the safest pair of hands in the team, missed the Sri Lanka opener Dimuth Karunaratne at second slip, when he had only four runs, and he went on to make 45 before becoming one of two victims for Liam Plunkett.

As the afternoon wore on however, Kumar Sangakkara and Mahela Jayawardene, both almost certainly playing their final innings in this country, put together a third-wicket partnership of 79 with such ease and grace that it appeared they would take the game right away from England. For the couple of hours they were together they made the bowling look mundane so that it was hard to tell if it was the pitch or the England team that looked the flatter.

Sangakkara was to go for 55 and Lahiru Thirimanne without scoring, but Jayawardene, moving with silky and ominous efficiency into the ball, will resume the fourth day also on 55 – of Sri Lanka’s 214 for four, he and Angelo Mathews (24) added an unbroken 38 for the fifth wicket.

They lead by 106, so the game is very much in the balance, with England desperate for wickets with the second new ball which is due in seven overs’ time. Another 100 or so runs for Sri Lanka and they will fancy their chances.

Yet Moeen may still just have turned the game, and in so doing, has gone some way to demonstrating why England see something more in his off-spin than many perceive. The television coverage includes the use of an instrument, a rev counter, that registers the amount of spin a bowler puts on the ball. Most finger spinners would reckon to be lucky to make 2,000 revolutions per minute. At his best, Graeme Swann believes he could generate more than 3,000. For his part, Moeen manages around 2,300, which Swann thinks was his lot in his last couple of years.

Alastair Cook had brought Moeen on from the football stand end to try and break a partnership between two of the finest players of spin bowling of their generation, a tall order for anyone, let along a novice. His response, with a little help in the pitch that had been evident when Rangana Herath bowled to England the previous day, was to remove both Sangakkara and Thirimanne.

This was no speculative bowling. In the first innings, he had tried to use flight and the drift that comes from the spin on the ball. Now, he bowled faster, flatter. Sangakkara pushed forwards, looking and playing for turn away from him, but the ball beat the inside of his bat and thudded into pad. The batsman, not quite believing the geometry of it, with Moeen bowling round the wicket, asked for the decision to be reviewed but was condemned by the result.

Two balls later, Moeen found one that pitched on the line of the left-hander Thirimanne’s middle and leg stumps, and turned past the bat to hit the top of middle and off. Thus did Thirimanne, out first ball in the first innings, complete a pair.

As Sangakkara had left the field, the crowd stood and applauded a great player who has batted brilliantly in this series, firstly at Lord’s where he composed a century of stunning simplicity; and here where the frenetic chancy display of the first innings was replaced by elegance.

When he eased Jimmy Anderson to the mid-wicket rope for his sixth boundary, it took him to 51, his seventh successive Test match half-century, a feat unsurpassed by anyone and equalled only by Everton Weekes (whose run of scores included five successive centuries), Andy Flower and Shivnarine Chanderpaul.

Here he had driven with precision, mostly through the covers off Anderson when the bowler overpitched in search of swing, but once – with what must be the shot of the match to date – sumptuously straight down the hill off the same bowler.

If that is to be the last memory of Sangakkara, then it is a snapshot worth having.