The hosts, replying to Pakistan’s first innings total of 551-6 declared, took their overnight score of 70-1 to 278-5 by stumps on the fourth day at the Sinhalese Sports Club.
Dilshan scored 121 and Sangakkara was unbeaten on 144 as the pair put on 225 runs for the second wicket.
Sri Lanka now need 74 more runs to save the follow- on today, the final day.
Ajmal under scanner
Meanwhile, concerns have been raised in Sri Lanka over the bowling action of Pakistan off-spinner Saeed Ajmal after the first Test in Galle.