At lunch, England were 193 for four - a lead of 52 - with Paul Collingwood 10 not out in what was the second of a three-match series.
Pietersen, who equalled his Test-best 158 in the drawn series opener at Lord's, was the first batsman in this match to reach fifty.
After wet weather had delayed the start by 80 minutes, England resumed on 138 for three, just three behind Sri Lanka's first innings 141 after pace bowler Liam Plunkett took three for 43 as the tourists collapsed on Thursday, having won the toss.
Pietersen was 30 not out and nightwatchman Matthew Hoggard unbeaten on two after off-spinner Muttiah Muralitharan, the cornerstone of Sri Lanka's attack, had taken two wickets and opener Andrew Strauss had run himself out for 30.
In overcast conditions, left-arm quick bowler Chaminda Vaas soon settled into a probing line and twice had Pietersen edging short of the slips.
At the other end, Sri Lanka captain Mahela Jayawardene gave Muralitharan the second over of the day.
But Pietersen cover-drove the spinner's first ball Friday for four to take England into a first innings lead in the 36th over. He later swept Murali for another boundary to go to a 53-ball fifty with one six and seven fours.
Next ball, Nuwan Kulasekara at long-on misread the spin off a drive and slipped to give Pietersen a second straight boundary before the following ball went for four byes.
However Sri Lanka did see the back of Hoggard. The tailender had added just one to his overnight score when Vaas knocked back his off-stump to end his 50-minutes innings and a stand of 44 with Pietersen to leave England at 169 for four.