Starting the third day at 179-1, Pakistan looked set to pick up a great score with debutant Azan Awais picking up where they left off on the previous day.
But Mehdi Hasan Miraz and Taskin Ahmed, who took 2 for 70, inspired Bangladesh to make a comeback by taking four wickets for just 20 runs in the opening hour.
Azaan, who became the 15th batsman and seventh opener for Pakistan to score a century on Test debut, was eventually dismissed for 103 off 165 balls with 14 fours.
