Moeen Ali's brilliant maiden Test century proved cruelly in vain for England as James Anderson fell to the penultimate ball against Sri Lanka on the final evening at Headingley.
Anderson was bounced out, looping a catch to leg gully off Shaminda Eranga, as England were bowled out for 249 to lose by 100 runs - and Sri Lanka, after all, recorded their first Test series victory in this country.
By then, it seemed England - like the tourists at Lord's last week - were about to hang on for a famous stalemate after Anderson kept out 54 balls, having joined Moeen (108no) with 20.2 overs remaining.
Moeen, in only his second Test, kept Sri Lanka at bay for more than six hours by batting out the whole of the last day before leaving the final over to his number-11 partner.
Eranga had the last say, though, after Dhammika Prasad (five for 50) and Rangana Herath (three for 59) had done the most damage.
The nail-biting outcome therefore does nothing to ease the pressure on the captaincy future of Alastair Cook, who led England to Ashes whitewash in Australia and was a notable survivor in his central role despite a management reshuffle around him.
England began the final morning here already 57 for five, and apparently with precious little hope of denying Sri Lanka.
That they almost did so was great credit to Moeen, yet the bottom line is that they have begun their new era after last winter's woes with a 1-0 series defeat.
Sri Lanka had been rampant on the fourth evening, Dhammika Prasad an unlikely bogeyman picking off four top-order batsmen, but in the morning they struggled to recreate that.
While England ended day four in a tailspin, they restarted with clear minds.
Joe Root was conspicuously defensive, scarcely offering a shot and rarely being forced to, with Moeen more ready to take runs when they were on offer.
In 17.4 overs, Root scored just three runs while Moeen managed 22 - including three boundaries off a noticeably tamer Prasad.
Rain came at 83 for one, first in showers and then heavily enough to force an early lunch at 12.30pm.
No overs were lost as a result and when the sides returned an hour later, things became considerably edgier in the middle.
Away captain Angelo Mathews appeared to be the instigator, using a break in play to launch some verbals in the direction of Root.
Root responded with a few choice words of riposte as tensions simmered enough for the umpires to step in at least twice.
Sri Lanka's bowlers then indulged themselves in a period of aggressive short-pitched bowling, though whether it was by tactical design or personal antipathy towards the Yorkshireman was unclear.
Either way, Eranga succeeded in clattering Root clean on the helmet as well as forcing a couple of awkward fends away from the body.
Moeen was enjoying a more low-key time, with no real sledging and no threat to his wicket as the 50 partnership passed by quietly.
Root suddenly emerged from his shell, striking three boundaries in 10 deliveries, but his improved confidence may have contributed to his downfall.
Root was tempted by Nuwan Pradeep to flick one off his legs but was straightened up and saw a leading edge carry to Lahiru Thirimanne in the gully.
Moeen's resistance continued with Matt Prior, with the all-rounder taking advantage of attacking fields with a couple of crisp fours off Herath.
A gentle single brought his half-century and he survived the double jeopardy of a DRS review by Herath that covered a leg-slip catch as well as an lbw.
Prior offered solid support for 15 overs but was undone when Prasad dug one at his ribs.
Just as he did against Eranga at Lord's, Prior got in a tangle and diverted the ball to short-leg where Kaushal Silva held a low chance.
It briefly looked as if a no-ball might save him but, having not been called on the field, a marginal decision by third umpire Paul Reiffel went with the bowler.
There was a sense of deja-vu just the other side of tea, but this time Reiffel ruled against Eranga and in favour of Chris Jordan as the seamer continued to flirt with the line.
Sri Lanka chiselled out their third wicket of the day when Herath won an lbw against Jordan's non-committal forward press and Moeen, rock solid and alive to punishing the occasional loose balls, was running out of partners.
Number nine Stuart Broad ate up time - asking the umpires to assess the light, leaving the fielders waiting with an unscheduled dash from the pitch - but departed after 24 balls when Herath landed another leg before.
That left Anderson and Moeen with 20.2 overs to face, an unlikely task but one that both men were hungry for.
Moeen took the strike where he could and endured an indecently long wait in the 90s before a gift from Pradeep took him to his ton.
His low-key celebration showed there were bigger goals on the horizon and when he played out Prasad's last over the match lay with Eranga and Anderson.
The number 11 played fourth balls dutifully before being bested by the fifth, sending Sri Lanka into raptures as he slumped defeated to the ground.