Chasing a record 340, England seemed well set as Jonathan Trott (112) and Matt Prior took them to 233-4.
But Prior’s dismissal to Rangana Herath (6-97) for 41 sparked the latest collapse of what, for Andrew Strauss’s side, has been a miserable winter.
England, the world’s top Test side, have now lost four successive matches.
And just as in their 3-0 series defeat by Pakistan earlier in 2012, the failure of the batting order was again to blame, with players unwilling to play patiently on a pitch that seemed to hold few demons.
Trott at least became the first England player this winter to reach three fingers, but elsewhere there were injudicious shots as players gifted Sri Lanka – and Herath in particular – their wickets.
However, Trott’s patient innings suggested that the total could have been attainable despite England’s previous highest chase being 332 against Australia in 1928.
The tourists had been narrow underdogs resuming on 111-2 with Pietersen and Trott at the crease and exhibiting contrasting levels of patience and a rush of blood from Pietersen swung the odds further in Sri Lanka’s favour.
Having added only one to his overnight 29, Pietersen played a poor shot to off-spinner Suraj Randiv, coming down the pitch and flicking to mid-wicket where he was caught.
There was a more disciplined and watchful mindset from Trott and Ian Bell who showed orthodox solidity – although Trott brought up his half-century with a reverse sweep.
Trott produced a rare blemish when he came close to being out caught and bowled, from a leading edge, with Herath putting him down on 62.
The curse of the pre-meditated sweep then struck England as Bell tried one, to a Herath delivery that turned out to be a half-volley, and led to an lbw. The decision was reviewed but there was no evidence of the thin edge that Bell felt he got.
His Warwickshire team-mate carried on neatly and defiantly until lunch and, after the interval, continued to grind down Sri Lanka’s attack, supported by an unusually restrained Prior.
When Trott brought up his hundred – with both men looking unhurried – England were sensing victory, but Prior then tried to up the ante and lost his wicket by sending a sweep off Herath straight to short leg. It was Herath’s tenth wicket of the match, leaving England 233-5.
Cool heads were needed as the tension mounted, but two wickets in quick succession suddenly put Sri Lanka in the ascendancy. Debutant Samit Patel failed for the second time in the match, hitting Herath to cover, and Trott’s heroic effort was ended when he nudged Randiv to leg-slip.
England required 84 with three wickets remaining and it proved well beyond them as they quickly subsided with Graeme Swann, James Anderson and Monty Panesar all offering minimal resistance. (BBC Sport)