Younus was unbeaten on 101 as the home team, replying to Sri Lanka's mammoth first innings total of 644-7, reached 213-2 at tea.
The other not-out batsman was Shoaib Malik with 46.
Younus, 31, pushed Sri Lankan paceman Dilhara towards third man for two to reach his 16th Test hundred after four hours and five minutes of defiant batting.
Younus found an able ally in Malik, whom he replaced as captain last month, as they put on 125 for the third wicket after opener Khurram Manzoor fell for 27 in his first Test.
Pakistan still need another 232 runs to avoid follow-on.
Resuming at 44-1, Manzoor and Younus took the score to 78 when Sri Lankan spinner Ajantha Mendis got the breakthrough, forcing Manzoor to edge to wicket-keeper Prasanna Jayawardene who took a straightforward catch.
Younus, who survived a confident leg-before appeal against Mendis when on 23, batted with responsibility to take the fight to Sri Lanka.
Malik, who lost the captaincy to Younus after Pakistan's 2-1 on