Jacques Kallis continued his magnificent run of form by collecting his 40th Test century -- and second in this series-deciding third Test against India -- to put South Africa on top after Day 4 in Cape Town.
The veteran all-rounder was unbeaten on 109, with the hosts all out for 341 to set India a target of 339.
Harbhajan Singh finished with seven wickets but his efforts were overshadowed by Kallis ahead of what promises to be an enthralling final day on a fast-deteriorating Newlands pitch.
The 35-year-old, who shared in a vital partnership of 103 with Mark Boucher (55) and also put on 54 with Dale Steyn (32) and 46 with Morne Morkel (29), achieved several landmarks along the way.
He became the first player from his country to score hundreds in each innings of the same match on home soil, while his third century of the series also saw him surpass the highest aggregate of runs by a South African for a three-match contest -- Daryll Cullinan's 427 against New Zealand in 1999 was the previous best -- with Kallis moving to 498.
He also overtook Ricky Ponting to move alone into second place for the most Test centuries -- Sachin Tendulkar leads the way with 51.
The feats of Kallis, who battled with a side strain, looked unlikely earlier when Alviro Petersen (22) and Hashim Amla (2) both fell cheaply as South Africa slumped from their overnight 52-2 to 64-4.
Kallis eventually reached his half-century from 134 balls.
Tendulkar grabbed an unlikely breakthrough with his part-time spin when a short and loose ball kept low, trapping Boucher lbw.
Steyn offered more good support for Kallis to take the total beyond 250, before being caught by Murali Vijay, handing Harbhajan his fifth wicket.
For Kallis, though, the records kept tumbling. His 100 came from 228 balls -- the second time he has managed two centuries in a Test, the first occasion coming in Pakistan in 2007.
Harbhajan grabbed the last two wickets of Morkel and Lonwabo Tsotsobe (8) with what proved to be the final deliveries of the day.
South Africa v India, Third Test, Day 5, Live, Sky Sports 1, 8.30am