Pakistan's fast bowlers reduced Bangladesh to 39-4 in its second innings at the end of day three on Sunday to leave the first cricket test evenly poised.
Bangladesh had secured a 44-run lead after bowling out Pakistan for 286, thanks largely to left-arm spinner Taijul Islam, who returned figures of 7-116.
Instead, the home side ended the day by extending its lead to 83 runs but has just six wickets remaining. Mushfiqur Rahim, who made 91 in the first innings, was batting on 12 and Yasir Ali on 8 after surviving several close calls.
Despite the first-innings deficit, Pakistan fought back through its fast bowlers — Shaheen Shah Afridi and Hasan Ali — who used the short ball to precision, leaving Bangladesh in a potentially precarious position.
Afridi cracked the game open, striking twice in his third over.
He trapped Shadman leg-before for 1 with a ball that swung sharply and then two balls later had Najmul Hossain caught at first slip for a duck with a short ball.
His short ball again worked for him when opener Saif Hasan gave the return catch and was dismissed for 14.
Ali also got into the act, dismissing captain Mominul Haque for a duck with a leading edge, leaving Bangladesh on 25-4.
Earlier, Taijul pegged back the Pakistan innings after the visitors began the day on 145 for no loss.
Opener Abid Ali top-scored with 133 off 282, hitting 12 fours and two sixes.
Taijul struck in the first over of the day, dismissing Abdullah Shafique and Azhar Ali via review with consecutive deliveries.
Shafique couldn't add any runs to his overnight total of 52.
Abid, who started the day on 93, flicked Taijul past square leg for a couple to reach his fourth century off 209 balls.
Skipper Babar Azam appeared to be in control before offspinner Mehidy Hasan's (1-68) quicker delivery rattled his stump for 10.
Taijul used his flight and variation well to curb the aggression of Pakistan's batsmen and reaped the rewards again when he spun one sharply to dismiss Fawad Alam (8), also via review.
He also got the key wicket of Abid Ali, who had used his feet nicely against the Bangladeshi spinners, and then dismissed Hasan Ali for his ninth and second consecutive five-for.
Fahim Ashraf kept Pakistan in the game, guiding the lower order before he was dismissed as the last batsman for 38.