England suffered a dramatic collapse in the final session after Paul Collingwood (40) and Ian Bell (78) had shared a four-hour partnership to take them to the brink of safety. Part-time spinner JP Duminy induced an edge from Collingwood to slip just after the match entered its final hour and three more wickets fell for 18 runs in 10.4 overs.
Duminy had Matt Prior caught close to the bat and Morne Morkel and Paul Harris grabbed wickets to leave England on 290 for nine with 2.5 overs remaining. But Swann and Onions, who also salvaged a draw for England in similar circumstances in the first test, defended stoutly to keep out fast bowlers Morkel and Dale Steyn.
England, set a victory target of 466, finished on 296 for nine.
Earlier, Collingwood and Bell batted through to tea, putting on 70 runs for the sixth wicket as they survived a ferocious spell of new-ball bowling from Dale Steyn.
South Africa took the second new ball one over after lunch and Steyn, bowling at high pace, beat the bat time and again but failed to find an edge as many of his deliveries were simply too exceptional for the batsman to touch.
England had stumbled to 179 for five at lunch with thoughts of a world-record run-chase of 466 long gone.
SCORE BOARD
SOUTH AFRICA (I innings): 291 all out
ENGLAND (I innings): 273 all out
SOUTH AFRICA (II innings): 447/7d
ENGLAND (II innings)
Strauss c Amla b Harris 45
Cook c Boucher b de Wet 55
Trott b Steyn 42
Pietersen lbw b Steyn 6
Anderson c Prince b Harris 9
Collingwood c Kallis b Duminy 40
Bell c Smith b Morkel 78
Prior c de Villiers b Duminy 4
Broad c de Villiers b Harris 0
Swann (not out) 10
Onions (not out) 0
Extras (B-1, LB-4, W-1, NB-1) 7
Total (for 9 wickets 141 overs) 296
Fall of wickets: 1-101, 2-107, 3-129, 4-153, 5-160, 6-272, 7-278, 8-286, 9-290.
Bowling: M Morkel 28-9-51-1, Steyn 35-11-74-2, F de Wet 12-5-23-1, Harris 40-14-85-3, Kallis 14-4-28-0, Duminy 12-3-30-2.