The batting feast at the Sinhalese sports club on Saturday saw Sri Lanka pile up a mammoth 756-5 declared in reply to South Africa's modest 169 to gain a match-winning lead of 587 runs.
The Proteas, who must bat out the last two days to save the game, were 43 for no loss in their second innings at stumps with Jacques Rudolph on 24 and Andrew Hall on 13.
Rudolph opened in place of Herschelle Gibbs, who cannot bat before five wickets have fallen after being off the field for four sessions with a stomach bug.
Skipper Jayawardene and Sangakkara, who came together on Thursday evening with their team on a precarious 14-2, destroyed the South African attack in the best ever partnership in the history of Test cricket.
The third-wicket pair surpassed the previous best of 576 for the second wicket by fellow-Sri Lankans Sanath Jayasuriya and Roshan Mahanama against India at the Premadasa stadium here in 1997.
Left-handed Sangakkara fell for 287, caught behind chasing a wide ball from Andrew Hall, but Jayawardene batted on to surpass Jayasuriya's Sri Lankan record of 340.
Jayawardene crossed West Indian Garfield Sobers' 365 not out and was one run away from equalling Brian Lara's 375 against England in 1994 when he was bowled by an express Andre Nel delivery.
Some 4,000 home fans fell silent, having expected Jayawardene to cross the three remaining milestones: Lara's 375, Matthew Hayden's 380 and Lara's world record score of 400 not out.
The 29-year-old, who declared at the fall of his wicket, received a standing ovation as he returned after a marathon innings lasting 12 hours and 42 minutes in hot and humid weather in the Sri Lankan capital.
Jayawardene hit 43 boundaries and a six during his 15th three-figure knock as the depleted South Africans wilted in the heat.
The Proteas, already without the injured duo of skipper Graeme Smith and Jacques Kallis, also missed veteran all-rounder Shaun Pollock, who opted out of the match following the birth of his second child.
Pollock will be available for the second Test of the short two-match series which starts at the Sara stadium here on August 4.
Left-arm spinner Nicky Boje bore the brunt of the assault, conceding 221 runs in 65 unsuccessful overs. Dale Steyn took 3-129 in 26 overs and pace spearhead Makhaya Ntini went for 0-97 in 31 overs.
There was little the South Africans could do to stop the rampaging Jayawardene and Sangakkara in good batting conditions.
It was the best display by two batsmen in a Test innings since Sobers made the unbeaten 365 and Conrad Hunte 260 for the West Indies against Pakistan in Kingston in 1957-58.
Left-handed Sangakkara's career-best knock, surpassing his 270 against Zimbabwe three years ago, lasted 11 hours and 15 minutes during which he hit 35 boundaries.
Skipper Jayawardene was on 309 when he saw his partner depart just before tea, but himself returned after the break in a bid to overtake Lara's record score.
The partnership record came in the second over after lunch through four byes conceded down the leg-side by wicket-keeper Mark Boucher off Boje.
Both batsmen, close friends off the field, hugged each other amid applause and a loud burst of firecrackers in the stands as umpire Mark Benson signalled the four byes.
Jayawardene, who is playing his 82nd Test, surpassed 6,000 runs during the course of his innings. Sangakkara, a veteran of 61 Tests, has hit four double hundreds in 10 century-making innings.