Hafeez fell for 196 and Azhar equalled his highest score as the tourists moved from their overnight position of 334-1 to 488-4 on a rain-hit second day at the Sinhalese Sports Club in Colombo.
Heavy showers on either side of lunch and just before tea allowed just 44 overs to be bowled in the day, in which Pakistan scored 154 runs.
Pics: Prabhas, Tamannaah Bhatia at 'Baahubali 2' first look launch at MAMI
'Ae Dil Hai Mushkil' photos: Aishwarya, Anushka, Karan get candid at MAMI
Photos: Huma Qureshi, Neha Dhupia and other celebs at MAMI
Photos: Amy Jackson, Daisy Shah at Mumbai airport
Photos: Sridevi, Irrfan and other celebs at 'Mughal-e-Azam' screening