Batsmen needed to spend time in the middle to score but nearly all of them lacked intent and hunger to do so.
Herath picked up with 11 wickets in the match.
Before lunch on day four, Pakistan was trailing the Sri Lankan first innings total of 419 by 79 runs with two wickets intact.
Herath was the hero with the ball as he took six wickets, while Dilruwan got three and Lakmal claimed one. Azhar Ali scored 85. No Sri Lanka batsman failed to suffer nervous moments against Yasir.
Niroshan Dickwella ensured Sri Lanka had something to defend with a pugnacious 40. He is followed by Kiwi legend Richard Hadlee and South African speed gun Dale Steyn, who both reached the milestone in 80 Test matches.
National Basketball Association changes 2018 All-Star Game format
Captains can choose any player who was voted to the All-Star Game as a starter or reserve, regardless of conference affiliation. Though the format is different, the selection process - 12 players from each conference earning bids - will remain the same.
The damage started in the fourth over itself. Sri Lankan captain Dinesh Chandimal expressed delight on his team's victory and said that it was the hard work of the players that paid off.
Abbas then went on to remove Suranga Lakmal for 13 before Yasir Shah joined the party and ripped through Sri Lanka's lower order.
So go Sri Lanka v Pakistan Tests, though - surely the most unpredictable and close-run rivalry of the past 10 years. And just nine runs added to the score, opener Shan Masood too departed being caught off Perera. Shafiq was given not out on a review when he was stumped off Herath on one.
It was Pakistan's smallest margin of defeat in terms of runs in their Test history as previously it was 24 runs loss which Pakistan suffered against Zimbabwe in 2013. Sarfraz Ahmed (16*) and Haris Sohail though, played with application and technique to guide them to the break. Then Pakistan took the match by the collar.
Azhar's defiant knock lasted more than five hours and included four boundaries, but with his dismissal Pakistan's hopes of building a lead faded. Herath returned to get rid of unsafe Hasan Ali and then cleaned up Mohammed Amir.
"It was a tough time, especially last evening", Chandimal said. And Mohammad Abbas walked into the middle like a goat into a slaughterhouse. In this way, Herath also became the oldest bowler to take 400 wickets.
The two teams will now meet each other in the second and final Test beginning October 6 at the Dubai International Stadium, Dubai.