The touring side, already 1-0 down in the series, had looked in serious trouble after being dismissed for 231 on the opening day.
But by the close of play on second day they had turned the game on its head, skittling their hosts for 229 in their first innings and then taking their overall lead to 47 with nine second-innings wickets remaining.
Kumar Sangakkara was 22 not out with Upul Tharanga on 17 and both looked comfortable after Michael Vandort (5) had fallen cheaply to Matthew Hoggard just as he had done in the first innings.
Sri Lanka's bowlers were as good as their front-line batsmen had been bad yesterday. Muralitharan, who had helped flay 62 for the last wicket on the opening day, yet again played the central role but this time with the ball, taking three for 62.
He dismissed Pietersen for 41 in the morning, then closed down one end completely during the rest of the innings. His 17-over spell between lunch and tea yielded the same number of runs and included nine maidens.
Pietersen, who has scored three hundreds in his last three home Tests, struggled as much as the rest of the England batsmen.
Having played a few false strokes at strike bowler Lasith Malinga, he lost patience at last by hoisting Muralitharan into the mid-wicket crowd.
The off spinner, though, celebrated two balls later when Pietersen, looking for more of the same, top-edged to Mahela Jayawardene at short fine leg.
Six balls later Andrew Flintoff (1) lazily edged Sanath Jayasuriya's left-arm spin straight to first slip and suddenly Sri Lanka were in total control.
England's only consolation was that, from 118 for five, their lower order managed to cobble together another 111 runs.
In the second test at Edgbaston, those last five wickets contributed just five to the team total.
Most of the credit went to Paul Collingwood, whose 48 runs, chiselled out during a three hour and 47-minute stay, represented the highest individual score of the match. Jon Lewis, batting at 10, also swiped 20.
Quite why both sides had struggled so much on an apparently fair surface and in sunny conditions is hard to explain.
England's problems in scoring during the last two sessions, however, were much easier to pin down.
Muralitharan did not give them anytning. The afternoon session seemed to belong to a bygone era as England managed a mere 52 runs in 35 overs. That session included just one boundary when, in a rare moment of aggression, Collingwood hoisted Muralitharan into the stands.
The Trent Bridge fans cheered ironically. They had come to the ground to watch Pietersen and Flintoff fireworks but had to make do with the likes of Liam Plunkett (nine runs in 72 minutes) and Hoggard (10 runs in 71 minutes).