Bangladesh's Taijul Islam claimed his ninth five-wicket haul while Pakistan's Abid Ali hit a century as the first Test remained delicately poised in Chittagong on Sunday.
The hosts bowled out Pakistan for 286 at the stroke of tea on the third day to take a 44-run lead into the second innings thanks to the mesmerising bowling of Taijul, who finished with 7-116.
But Pakistan struck back in spectacular fashion with Shaheen Afridi dismissing Shadman Islam (one), Najmul Hossain (zero) and Saif Hasan (18) to finish the day 3-6 and reduce Bangladesh to 39-4 at stumps.
Hasan Ali also scalped the wicket captain Mominul Haque for a duck to rob the hosts of their advantage.
Mushfiqur Rahim remained unbeaten on 12 alongside debutant Yasir Ali, 8 not out.
Ali earlier made 133 off 282 balls, holding one end for Pakistan for a long stretch after Taijul's early strike of two wickets in two balls in the day's first over.
"Some patches are forming in the wicket for both off-spinners and left-arm spinners," Ali said.
"But we will definitely try to achieve whatever target is set for us," he added.
Faheem Ashraf added 38 late in the innings to keep Pakistan in contention before he was last man dismissed.
Pakistan, who resumed on 145-0 and looked poised for a big total, suffered an early setback when Taijul trapped debutant Abdullah Shafique leg-before on his fifth ball.
Shafique left without adding to his overnight 52, and Taijul took Azhar Ali for a duck in the very next ball when the delivery hit him on the foot.
Azhar was initially given not out but the decision was reversed on review.
Babar Azam saw off the hat-trick ball in Taijul's next over but did not survive long.
Mehidy uprooted his off-stump with a straight delivery after the Pakistan skipper made only 10 runs.
Taijul grabbed his third wicket when he beat Fawad Alam with spin to remove the batsman for eight.
Taijul said he had to play with extra responsibility in the absence of injured Shakib Al Hasan.
"Since he isn't playing, I had to assume his role," he said after stumps. "I have to manage the wicket-taker's role as well as maintaining economy."
Bangladesh sought a review after the umpire turned down a confident caught-behind appeal.
The replay indicated the ball took a feather touch on Alam's glove, ending his brief stay at the crease.
Ali, who struck 12 fours and two sixes, was also lucky to survive after he was dropped at slip by Najmul Hossain off Taijul at 113.
He was dropped again by Yasir Ali at forward short leg on 133 but it did not cost Bangladesh much, with Taijul taking him leg before two balls later.
Pakistan had by then lost Mohammad Rizwan to Ebadot Hossain, who bowled 2-47.