Petersen’s unbeaten 124 came from 266 balls with 16 fours, while Graeme Smith hit 52, from 93 balls with four fours.
Stuart Broad, who took 55 for 1, bowled AB de Villiers and Steven Finn (78 for 1) bowled Dale Steyn shortly before stumps to keep England in contention.
James Anderson, with 42 for 1 and Tim Bresnan with 68 for 1, also took wickets.
A major talking point came in the 12th over of the day when Smith edged to Andrew Strauss at first slip, only for the ball to be ruled dead because paceman Steve Finn had dislodged the bails on his follow through.
England captain Strauss had an animated discussion with umpire Steve Davis, but law 23.4, section 6 of cricket’s rules says: “An umpire shall call and signal dead ball when the striker is distracted by any noise or movement while receiving.”
Smith was on 6 when he was reprieved by the dead ball decision. Finn, who has collided with the stumps throughout his career, had previously knocked the bails off twice during the morning session.
Finn’s inclusion in England’s team was unexpected. In a major surprise, England left out Graeme Swann, making it the first Test the hosts have played without a specialist spin bowler since 2003 — also against South Africa at Headingley.
Although there was only partial cloud cover, England chose to bowl after winning the toss, a gamble that initially appeared to backfire.
After 45 fruitless minutes, Anderson finally drew an edge when Petersen was on 29. But Alastair Cook, who was fielding in Swann’s usual position of second slip, dropped an easy chance.
Smith clearly wasn’t distracted when Finn knocked into the stumps for a fifth time in the 20th over because he pulled the ball to the deep midwicket fence, only for Davis to again call dead ball and negate the boundary.
Smith was denied another boundary in identical fashion in the first over after lunch.
England finally ended a spell of 10 hours, 3 minutes without a wicket — since Smith fell on the third day of the first Test at The Oval — when South Africa’s captain chipped a leg-side delivery from Bresnan to Ian Bell.
Hashim Amla got an inside edge to the sixth ball he faced, from Broad, but it just eluded the stumps and diving wicketkeeper Matt Prior to fly to the boundary for four.
Amla’s drove the next delivery stylishly for four, but he was bizarrely run out for 9 after a misfield. Amla’s drive squirted through Kevin Pietersen at cover, but Bresnan retrieved the ball near the boundary and Amla failed to make his ground when looking for a third run.
Jacques Kallis looked dangerous. But when he fell to Anderson for 19 in the 50th over to a low catch by Cook, the Test was delicately poised at 157 for 3, with the three batsmen who tormented England at The Oval all back in the dressing room.
After a 73-minute rain delay the evening session began in attritional fashion with England drastically reducing the run rate.
Petersen brought up his century from 215 balls as South Africa gradually regained control, though in the first over with the new ball Anderson — also fielding in Swann’s customary second slip position — dropped de Villiers off Broad.
Petersen was given out lbw to Finn when he was on 119 but he successfully referred the call.
England’s luck finally turned when de Villiers played on to Broad for 47 in the 83rd over and Finn clean bowled the nightwatchman Steyn for 0 in the 85th to drag England back into contention.