Pace bowler Hasan Ali led Pakistan earlier with the ball, finishing with 5-51, his sixth five-wicket, which kept Bangladesh in check after the hosts resumed with 253-4 in the morning.
Liton Das top-scored with 114 for Bangladesh, adding just one run to his overnight score, while Mushfiqur Rahim, unbeaten on 82 at the end of the opening day's play, fell for 91 runs.
Mehidy Hasan struck an unbeaten 38 to take Bangladesh past 300 before he claimed two wickets in two balls to bring an end to Bangladesh's efforts with the bat.
"When we lost four wickets before lunch, everyone thought we would be bowled out early. Mushfiqur and I put together a good partnership," said Liton.
"By the end of the day, we were thinking about a big total. But cricket is unpredictable. Pakistan are in a good position now. If we can take two or three wickets tomorrow morning, we will be back on par."
Pakistan had Bangladesh on the ropes on day one at 49-4 but the hosts fought back thanks to Liton and Mushfiqur.
Pakistan looked sharp right from the start of the second day's play when Hasan trapped Liton leg-before in the second over of the morning.
Struck on his backfoot, Liton was initially given not out but Pakistan successfully reviewed the decision.
Liton, who shared 206 runs with Mushfiqur in the fifth wicket, hit 11 fours and a six in his 233-ball innings.
Hasan then dismissed Yasir Ali for four with a fine in-swinger that rattled the leg and middle stumps of the debutant.
Faheem took a thin edge from the bat of Mushfiqur, effectively ending Bangladesh's chance for a big total.
Mushfiqur struck 11 fours in his 225-ball stay at the crease.