The 29-year-old hit 138 over the course of a marathon 333 minutes and brought Bangladesh back into the match with a fighting 165-run seventh-wicket stand alongside Mehidy Hasan Miraz, who scored a pugnacious 78.
At close on the third day, Bangladesh struck back to leave Pakistan on a sluggish 9-2, with opener Abdullah Shafique dismissed for three and nightwatchman Khurram Shahzad falling without scoring — both to pacer Hasan Mahmud.
Saim Ayub was not out on six as the home team lead by 21 runs, and Pakistan will need to bat smartly to clinch a series-levelling win after losing the first Test, also in Rawalpindi, by 10 wickets.