England, replying to the tourists' 419, have rekindled hopes of a narrow victory thanks to Pietersen's remarkable innings of 149 not out from 212 deliveries including 22 fours and a six. Matt Prior was on 20 at the close.
Pietersen received able assistance from debutant James Taylor (34), who was content to play a supporting role while Pietersen flayed the South African bowlers to all parts of the ground. Their match-defining partnership was worth 147.
Diminutive Nottinghamshire batsman Taylor joined Pietersen when the score was 173 for four and with England still 246 runs adrift of the Proteas' total. They had lost three wickets in an extended afternoon session but the duo turned the match on its head.
England, 1-0 down after losing at The Oval by an innings and 12 runs, must win here and at Lord's to claim the three-match series, or avoid a series defeat to stay top of the world rankings ahead of the South Africans.
Pietersen was at his destructive best and some of his stroke-play was a mixture of nonchalance and arrogance, but certainly highly-skilled.
He went from 95 to 99 with a majestic cover drive off the back foot from the bowling of Vernon Philander. Next ball he scampered a quick single to go level with captain Andrew Strauss on 21 Test centuries, the second most by an Englishman. Wally Hammond, Colin Cowdrey and Geoff Boycott all scored 22.
Pietersen also passed 7,000 Test runs in the process, becoming the quickest to reach the landmark in seven years and 14 days. Previous record holder Graeme Smith had taken eight years and two days.
But the innings was worth more than statistical highs for the sake of the game and the crowd's pleasure. Pietersen went from his tea time score of 43 to 69 in just 11 balls, with six boundaries.
Perhaps his finest shots came in the same over, bowled by Dale Steyn. First he played a flick-pull through midwicket for four, and then lofted the world's number one bowler over his head for six. Steyn looked visibly shocked.
Before lunch, Alastair Cook was lbw to Philander for 24, failing in his attempt to overturn Steve Davis's decision. Then three batsmen fell in an extended afternoon session because of a rain storm in the morning.
Andrew Strauss (37) got a faint edge to a ball just outside off stump from fast bowler Dale Steyn and was caught behind, while Jonathan Trott (35) unusually fell to a loose shot when he tried to late cut a wide ball from Steyn only to nick to Graeme Smith at first slip.
Ian Bell, who looked in confident form when striking leg-spinner Imran Tahir for a six over his head, was out five minutes before tea, playing a loose stroke to an out-swinger from Jacques Kallis and was caught by Graeme Smith.
Taylor finally succumbed when he got an inside off Morne Morkel and was bowled.