Defeat stares in Bangladesh face in first Test
Stay tuned with 24 News HD Android App
Just when Bangladesh seemed to have fought their way back into the match at 124-2 minutes before the close on the third day, Naseem destroyed them with three wickets off successive deliveries.
Aged 16 years and 359 days, he becomes the youngest player to record a Test hat trick, besting Bangladeshi Alok Kapali who achieved the feat aged 19 in 2003.
Naseem trapped Najumul Hossain Shanto leg before off the fourth ball of his seventh over for 38, then followed up with dismissals of Taijul Islam (lbw) and Mahmudullah (caught) with the next two deliveries.
Naseem had figures of 4-26 before he left the field with a shoulder injury.
Shanto and Mominul Haque, unbeaten on 37 at the close, had added 71 for the third wicket after they lost Saif Hassan on 16 and Tamim Iqbal on 34.
At the close, Bangladesh were 126-6 and needing another 86 runs to avoid an innings defeat with two days to play.
Naseem, who burst onto the scene on Pakistan's Australia tour last year, is also the youngest fast bowler and second bowler overall to take five wickets in a Test innings.
He achieved that feat at 16 years and 307 days against Sri Lanka in Karachi last year.
Pakistan were bowled out for 445 in their first innings with Babar Azam scoring 143 and Haris Sohail 75.
Saif, playing his first Test, was on a pair after his second-ball duck in the first innings but he started confidently to reach 16 with four boundaries before he was bowled by Naseem.
Iqbal, fresh from scoring the highest first-class score on Bangladeshi soil of 334 not out last week, was trapped leg-before by Yasir.
Earlier, Pakistan lost seven wickets either side of lunch with Sohail holding the innings together.
He struck seven fours and two sixes for his third Test half-century before holing out off spinner Taijul Islam to deep mid-wicket. Last man Naseem was run out to end Pakistan's first innings.
A healthy 10,000-strong holiday crowd had come in anticipation of popular batsman Babar Azam scoring a double hundred. But resuming at 342-3, Pakistan lost Azam to the first ball of the day.
Azam seemed caught in two minds whether to play or leave a length delivery from pace bowler Abu Jayed and edged to Mohammad Mithun at first slip.
Azam's 143 was his fifth Test hundred and a masterclass of attractive batting, which included a six and 18 fours. Asad Shafiq, who put on 137 for the fourth wicket with Azam, added just five to his overnight score before he was caught behind off fast bowler Ebadot Hossain for a 65 that included nine boundaries.
Jayed was the pick of the bowlers with 3-86 while Islam finished with 2-139.