The hosts, who resumed their second innings at 63-1 chasing an improbable target of 550, were shot out for 221 in the post-lunch session of the fourth day at the Sher-e-Bangla stadium.
Shah, who took three for 58 in the first innings, once again baffled the Bangladesh batsmen with his leg-spin and googly on the wearing pitch to grab four for 73 in the second knock.
Mominul Haque played a lone hand for the hosts with 68, joining West Indies great Vivian Richards and the Indian duo of Virender Sehwag and Gautam Gambhir as the only batsmen to score 50 runs or more in 11 consecutive Tests.
The match ended at the fall of the ninth wicket as Shahadat Hossain was unable to bat after suffering a serious knee injury on the first day.
More From This Section
The win helped Pakistan end an otherwise dismal month-long tour on a positive note after being routed 3-0 in the one-day series and losing to Bangladesh for the first time in a Twenty20 international.
It was Bangladesh's ninth loss to Pakistan in 10 Tests, the only consolation coming through a draw in the first Test of the short series in Khulna last week.
Seamer Imran Khan, a late replacement for the injured Rahat Ali, dealt two major blows when he removed the in-form Tamim Iqbal and Mohammad Mahmudullah in the space of nine runs.
Tamim, who slammed a double-century in the first Test, was caught behind by wicket-keeper Sarfraz Ahmed for 42 as he slashed at a short delivery from Imran.
Mahmudullah made two when he edged Imran to second slip where Younis Khan picked up the catch on second attempt as Bangladesh slipped from 86-1 to 95-3.