But fast bowler Umar Gul helped Pakistan, 1-0 down in the four-match series, fight back late on by taking two wickets with the new ball to get rid of recalled wicket-keeper Chris Read (38) before bowling nightwatchman Matthew Hoggard for nought with a full-length delivery.
In all Gul had four for 73 from 18.4 overs.
Ian Bell, who scored centuries in the first two Tests, was 66 not out.
Earlier South Africa-born Pietersen had been seemingly caught on two, caught off a no-ball on 29 and dropped on 104, recalled seamer Shahid Nazir the unlucky bowler on each occasion.
Read was lbw to the persevering Gul shortly before stumps having equalled his Test-best score and put on 86 with Bell.
By tea Pietersen, who'd gone six innings without fifty, was 82 not out and he then completed his fifth hundred in his 17th Test.
Successive fours off pace bowler Mohammad Sami took Pietersen to 99.
But he then had several minutes of treatment for cramp in his left forearm.
However, a pull down to fine leg off Sami took him to a 123-ball hundred in just over three hours with two sixes and 15 fours.
It was the 26-year-old's second century against Pakistan after he'd made exactly 100 at Faisalabad in November.
And it was also England's seventh hundred in three Tests, with Marcus Trescothick the only member of their top six yet to reach three figures this series.
Then, on 104, Pietersen slapped Nazir to mid-wicket where Salman Butt dropped the catch.
Pietersen, still suffering, then exited with England 259 for four.
His temporary departure brought Read, replacing the dropped Geraint Jones because of the latter's lack of runs, in for his first Test innings in two years since playing against the West Indies in Barbados.
Read, who last month scored an unbeaten 150 for England A against Pakistan, found his touch after getting off the mark with an inside edge.
The stylish Bell then completed a 101-ball fifty with five fours.
Pakistan, with 10 overs left in the day, took the new ball with England 328 for four and fast bowler Gul made it count.
Pietersen, together with Paul Collingwood (31), had shared a stand of 82 as England recovered after lunch.
Pakistan, beaten inside three days during an innings and 120-run defeat in the second Test at Old Trafford, fought back to have England 110 for three at the interval.
Alastair Cook, off the last ball before lunch, was caught and bowled by Gul for 23 after scoring hundreds in the first two Tests.
Nazir, playing his first Test since appearing against Sri Lanka at Lahore in 1999 and only the ninth since his debut 10 years ago, had Pietersen caught behind off the inside edge but Australian umpire Darrell Hair signalled a no-ball.
Pietersen then lofted leg-spinner Danish Kaneria over long-off for six.
Meanwhile Collingwood carelessly miscued a pull off Gul to Taufeeq Umar at mid-wicket, England 192 for four.
Bell got off nought with an off-driven four off Gul before Pietersen drove Kaneria for another six.
England started well but lost both their openers, Trescothick (28) and captain Andrew Strauss (36) with the score on 67.
The previously wayward Sami struck in the first over after the drinks break when he juggled a caught and bowled chance to dismiss Trescothick.
Four balls later Trescothick's fellow left-hander Strauss exited when he edged Nazir to Younis Khan at second slip.
Nazir ought to have had Pietersen, on two, caught behind after replays showed he'd edged the ball on to his back leg.
Strauss chose to bat despite the overcast conditions which usually assist swing bowling at Headingley but, in the opening stages, Pakistan pitched too short to benefit from the cloud cover.
England 1st Innings
Fall of wickets: 1-67, 2-67, 3-110, 4-192, 5-345, 6-347
To bat: S Mahmood, M Hoggard, S Harmison, M Panesar
Pakistan: Taufeeq Umar, Salman Butt, Younis Khan, Inzamam-ul-Haq (capt), Mohammad Yousuf, Faisal Iqbal, Kamran Akmal (wkt), Mohammad Sami, Shahid Nazir, Umar Gul, Danish Kaneria
Umpires: Darrell Hair (AUS), Billy Doctrove (WIS)
TV umpire: Nigel Llong (ENG)
Match referee: Ranjan Madugalle (SRI)