The overnight pair batted through the first two sessions of the second day to put on 306 runs, Sri Lanka's highest stand for the third wicket against any country, without a hint of trouble.
Left-handed Sangakkara was unbeaten on 147 and skipper Jayawardene was on 145 not out as Sri Lanka went to tea at 320-2 on Friday, a lead of 151 runs over South Africa's first innings total of 169.
Sri Lanka will be looking to bat the depleted Proteas out of the match in good batting conditions at the Sinhalese sports club.
Sangakkara, freed of his dual role as wicket-keeper after Sri Lanka opted to play a specialist keeper in Prasanna Jayawardene, batted fluently to strike 18 boundaries in his 10th Test century.
His captain also produced glorious strokeplay at the other end, helping himself to 19 fours in his 15th century.
The duo surpassed Sri Lanka's record third-wicket stand of 262 by Jayawardene and Thilan Samaraweera against England at the same venue in 2003.
Jayawardene and Sangakkara came together on the first evening with Sri Lanka a shaky 14-2 after seamer Dale Steyn removed openers Sanath Jayasuriya and Upul Tharanga in his first two overs.
South Africa, already without regular captain Graeme Smith and Jacques Kallis, missed veteran all-rounder Shaun Pollock, who opted out of the first Test following the birth of his second child.
Pollock, who arrived here late Thursday, will be available for the final Test of the short two-match series which starts at the Sara stadium here on August 4.
Stand-in captain Ashwell Prince rotated his five bowlers in hot and humid conditions, but few deliveries beat the broad bats of Sangakkara and Jayawardene.
Sri Lanka, who began the day 41 runs behind South Africa's meagre total, took the lead in the first hour of play, which produced 51 runs in 13 overs.
Sangakkara reached his century 30 minutes before lunch when he lofted Nicky Boje for two runs, the ball narrowly eluding a diving Jacques Rudolph near the mid-wicket fence.
Jayawardena, 99 at lunch, completed his hundred off the first ball after resumption, pulling Steyn to the fine-leg fence for his 14th boundary.
Both batsmen were on 143 each when the partnership touched the 300-run mark 10 minutes before tea.