Paceman Suranga Lakmal had Younis caught behind for 77 in the 11th over of the day but Pakistan reached 189-4 at lunch on the fourth day at Dubai stadium as they inched towards making their opponents bat again.
With his side needing a further 34 runs to avoid an innings defeat, skipper Misbah-ul Haq was unbeaten at the break after a gritty 74, with Asad Shafiq not out 18.
Sri Lanka have never defeated Pakistan by an innings in the 44 previous Tests between the two nations. The first Test in the three-match series ended in a draw in Abu Dhabi last week.
Younis batted for 235 minutes and hit five boundaries, adding 129 runs for the third wicket with his skipper.
More From This Section
Misbah, who took 38 balls to add to his overnight score of 53, has so far hit seven boundaries and a six during his resolute knock.
Shafiq, who hit a hundred in Dubai against South Africa in October last year, had some anxious moments but survived to reach lunch.