The stylish left-hander (319) was the last Sri Lankan batsman to fall after a marathon 482-ball knock that included 32 boundaries and eight sixes as the tourists amassed 587 before being all out when second day's tea was called.
In reply, Bangladesh were 86 for one wicket at stumps, after losing opener Tamim Iqbal for a duck in the first over of their innings at Chittagong's Zahur Ahmed Chowdhury Stadium.
Shamsur Rahman (45) and Imrul Kayes (36) both survived a dropped chance each to remain unbeaten at close, with the hosts still trailing Sri Lanka by 501 runs.
Batting on 286 with number 11 batsman Nuwan Pradeep, Sangakkara hit left-arm spinner Shakib Al Hasan for a four and two sixes off successive deliveries to go past his previous best score of 287 and reach his maiden triple hundred in spectacular fashion.
Sangakkara, 36, is fastest to the 11000 Test-run club, having bettered West Indies batting great Brian Lara's record by five innings.
Kithuruwan Vithanage (35) and Ajantha Mendis (47) provided able support to Sangakkara and added 90 and 100 for the sixth and eighth wickets respectively.
All-rounder Shakib completed his 11th five-wicket haul but Bangladesh would require something of a miracle to win the Test and square the two-match series after losing the first match in Dhaka by an innings and 248 runs.
Scorecard
Sri Lanka (1st innings): (overnight 314-5)
D. Karunaratne c Mahmudullah b Al-Amin 31
K. Silva lbw b Gazi 11
K. Sangakkara c Gazi b Nasir 319
M. Jayawardene lbw b Mahmudullah 72
D. Chandimal c Kayes b Shakib 27
A. Mathews b Shakib 5
K. Vithanage lbw b Nasir 35
D. Perera lbw b Shakib 1
A. Mendis lbw b Shakib 47
S. Lakmal lbw b Shakib 0
N. Pradeep not out 4
Extras: (b-21, lb-6, w-2, nb-1, pen-5) 35
Total: (all out; 156.4 overs) 587
Fall of wickets: 1-39, 2-49, 3-227, 4-294, 5-312, 6-402, 7-405, 8-505, 9-533
Bowling: Al-Amin 25-5-81-1 (nb-1), Gazi 48-4-181-1, Razzak 4-1-6-0, Shakib 34-3-148-5 (w-1), Mahmudullah 34-2-110-1 (w-1), Nasir 6.4-0-16-2, Shamsur 1-0-5-0, Mominul 4-0-8-0.
Bangladesh (1st innings):
Tamim Iqbal b Lakmal 0
Shamsur Rahman not out 45
Imrul Kayes not out 36
Extras: (nb-5) 5
Total: (one wicket; 25 overs) 86
To bat: Mominul Haque, Shakib Al Hasan, Mushfiqur Rahim, Nasir Hossain, Mahmudullah, Sohag Gazi, Al-Amin Hossain, Abdur Razzak
Fall of wicket: 1-0
Bowling: Lakmal 5-0-18-1, Pradeep 7-2-29-0 (nb-3), Mendis 4-1-13-0 (nb-2), Perera 7-2-22-0, Mathews 2-0-4-0
Image: Kumar Sangakkara
Photograph: Getty Images
Pietersen pays the price... for England's failure!
Kaushal Silva hits maiden Test ton as Lanka swell lead vs Bangladesh
Jayawardene joins 11,000 Test club
Injured Sri Lanka bowlers Herath, Eranga out of Bangladesh tour
Auto Expo 2014: Bajaj ready to roll out quadricycle