Pietersen's 142 was the centrepiece of England's 295 all out at tea on the second day of the second Test, still a healthy lead of 154, after they bowled out Sri Lanka for a meagre 141 in their first innings.
Pietersen, who equalled his Test-best 158 in the drawn series opener at Lord's, became the first England batsman to score hundreds in successive Tests against Sri Lanka.
But just when it seemed as if England were on their way to an overwhelming position, Pietersen's exit sparked a collapse that saw the last five wickets fall for five runs in 29 balls.
Off-spinner Muralitharan was the destroyer-in-chief with six for 86, the 52nd time he'd taken five or more wickets in a Test innings and fifth against England.
At lunch, England were 193 for four with Pietersen 65 not out and Paul Collingwood unbeaten on 10 in what was the second of a three-match series.
Pietersen was seeing the ball well, cover-driving Farveez Maharoof for a stylish four and repeating the dose off the first ball off Nuwan Kulasekara's new spell to go to 94, the Sri Lankan back-up seamers lacking the pace or movement to trouble the South Africa-born Hampshire batsman.
Then a boundary through mid-wicket off Kulasekara saw Pietersen to his fourth Test hundred in just 115 balls with one six and 16 fours.
The 25-year-old's progress after lunch was especially rapid, Pietersen needing a mere 31 balls, including seven fours, to go from 65 to 100.
But Muralitharan kept Sri Lanka going when he had Collingwood (19) caught off bat-and-pad by Upul Tharanga at short leg to end a stand of 69 with England 238 for five.
Pietersen, on 104, appeared fortunate to survive a confident lbw appeal from Muralitharan although Australian umpire Darrell Hair in fact gave him a single. Undeterred, Pietersen on-drove Kulasekara for six, the second time he'd cleared the ropes after lofting Muralitharan on Thursday.
Pietersen, using his feet, later struck Murali for three straight fours and then flamboyantly reverse-swept him for an extraordinary six.
But two balls later Murali had Pietersen plumb leg before, sweeping.
England captain Andrew Flintoff was then bowled by Lasith Malinga for nine before Murali removed Liam Plunkett and Geraint Jones cheaply. Monty Panesar was last man out, lbw to Malinga for nought.
England, after wet weather had delayed the start by 80 minutes, resumed on 138 for three, just three behind.
Their position owed much to paceman Plunkett's haul of three for 43 on Thursday.
Pietersen was 30 not out and nightwatchman Matthew Hoggard unbeaten on two.
Hoggard had added just one to his overnight score when Chaminda Vaas knocked back his off-stump to end his 50-minutes innings.