The tourists, electing to bat in overcast conditions, slumped to 56-3 before Khan's rescue act helped them recover to 261-4 when bad light ended play two overs early at the Galle International Stadium.
The 36-year-old middle-order batsman, who came to bat in his 90th Test at 19-2, hit 11 boundaries and a six in his 24th century. Only Inzamam-ul Haq (25) has more Test hundreds for Pakistan.
Skipper Misbah-ul Haq, making a typically dour but determined 31, put on 100 for the fourth wicket with Khan before he was caught behind off left-arm spinner Rangana Herath.
Khan was given a reprieve by the Decision Review System (DRS) when he was on 59 after umpire Bruce Oxenford had declared him leg-before to off-spinner Dilruwan Perera.
More From This Section
Television replays showed the ball pass over the stumps.
The partnership between Khan and 40-year-old Misbah came after Sri Lanka dominated the morning session with three quick wickets.
Seamer Dhammika Prasad removed both openers cheaply to make it 19-2 by the sixth over before a partial recovery helped the tourists move to 59-3 by lunch.
The seamer then trapped Khurram Manzoor leg-before in his third over, but Azhar Ali and Khan settled in to put on 37 as the wicket eased out under the mild sun.