Taijul Islam claimed his ninth five-wicket haul to put Bangladesh on top in the first Test against Pakistan on Sunday despite Abid Ali's century.
The hosts bowled out Pakistan for 286 on 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.
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 a setback very early 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.
Taijul grabbed his third wicket when he beat Fawad Alam with spin to remove the batsman for eight.
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.
His dismissal cruelled Pakistan's chance of a comeback, having already lost Mohammad Rizwan to Ebadot Hossain, who bowled 2-47.