The wicketkeeper-batsman's stylish 185, his ninth Test century, helped the home side to declare their second innings at a massive 448-5 for an overall lead of 457.
Wily off-spinner Muttiah Muralitharan then struck twice as Pakistan reached 89-2, needing another 369 for an improbable win. Shoaib Malik (30) and Faisal Iqbal (nine) were the not out batsmen.
The highest-ever total to win a Test is 418, achieved by the West Indies against Australia at Antigua in 2003.
Left-handed Sangakkara, 28, put on 158 for the third wicket with stand-in skipper Mahela Jayawardene (82) and 144 for the next with Thilan Samaraweera (64).
Sangakkara, who was on 77 in his team's overnight total of 242-2, smashed 22 fours in his 326-ball knock. It was his third century against Pakistan, and the second in a row against them following his 138 in the last Test at Karachi in 2004.
Pakistan needed a couple of early wickets to bounce back into the game and took the second new ball immediately it was due, but could taste just one success in the extended morning session.
Seamer Mohammad Asif had Jayawardene caught hooking by Abdul Razzaq in the morning's 12th over. The Sri Lankan captain added 13 to his overnight score of 69.
But Sangakkara continued to dominate the seam-spin attack with a wide range of shots, hitting Razzaq for three successive fours before completing his century in the morning.
"I just wanted to go out there and spend some time in the middle, try to grind the bowling. With Mahela and Thilan batting very well, it was easy to get into a position of strength," Sangakkara said.
"I think we have a very good chance to win the match and have to just stick to the basics," he added.
Pakistan grabbed two wickets in the afternoon session when Sri Lanka went for quick runs before the declaration.
Sangakkara's innings ended when he mistimed a sweep off spinner Malik and was caught by skipper Inzamam-ul-Haq at mid-wicket.
Samaraweera fell after completing his 12th Test half-century, caught by Imran Farhat in the covers off leg-spinner Shahid Afridi.
Asif, who wrecked Sri Lanka in the first innings with four wickets, was again the most successful bowler with 2-71.
Key Pakistani leg-spinner Danish Kaneria only managed one wicket for 138 runs off 36 overs.
Pakistan started steadily in their second innings with openers Malik and Farhat (34) adding 59 before Muralitharan grabbed two scalps.
Muralitharan had Farhat caught by Jayawardene at slip and then bowled Younis Khan (eight) to reduce the visitors to 71-2.