Sangakkara was unbeaten on 160 as Sri Lanka reached the close of play on 314 for five after captain Angelo Mathews had won the toss and opted to bat.
The stylish left-hander added 178 for the third wicket with Mahela Jayawardene (72) after Bangladesh dismissed openers Dimuth Karunaratne (31) and Kaushal Silva (11) cheaply.
The 36-year-old Sangakkara, who went to his half-century with a six off spinner Mahmudullah, brought up his hundred with a boundary to fine leg off the same bowler.
Jayawardene also looked set for his 34th Test hundred but was out leg before to Mahmudullah after playing across the line.
Sangakkara and Dinesh Chandimal (27) then put 67 for the fourth wicket before the latter was caught at point as he danced down the wicket to left-arm spinner Shakib.
All-rounder Shakib then bowled captain
Bangladesh, crushed in the first Test in Dhaka by an innings and 248 runs, dropped Marshall Ayub, Rubel Hossain and Robiul Islam and brought in batsman Imrul Kayes, all-rounder Mahmudullah and left-arm spinner Abdur Razzak.
Paceman Nuwan Pradeep and spinner Ajantha Mendis replaced the injured Shaminda Eranga and Rangana Herath in the Sri Lankan team.
Scoreboard:
Sri Lanka first innings
D. Karunaratne c Mahmudullah b Al-Amin 31
K. Silva lbw b Gazi 11
K. Sangakkara not out 160
M. Jayawardene lbw b Mahmudullah 72
D. Chandimal c Kayes b Shakib 27
A. Mathews b Shakib 5
K. Vithanage not out 0
Extras (b-5, lb-2, nb-1) 8
Total (five wickets; 92 overs) 314
Still to bat: N. Pradeep, A. Mendis, S. Lakmal, D. Perera
Fall of wickets: 1-39, 2-49, 3-227, 4-294, 5-312.
Bowling: Al-Amin 19-4-56-1 (1nb), Gazi 30-4-98-1, Razzak 4-1-6-0, Shakib 15-1-70-2, Mahmudullah 22-2-70-1, Nasir 1-0-2-0, Shamsur 1-0-5-0.
Kaushal Silva hits maiden Test ton as Lanka swell lead vs Bangladesh
Sri Lanka in command after Jayawardene's double ton
Pakistan strike early but Sri Lanka extend lead to 220
Sri Lanka crush Bangladesh with a day to spare
Can India maintain their stay in the second spot in Tests?