Paceman Suranga Lakmal took all three wickets to fall on the fifth morning to finish with a career-best 4-78 to wrap up Pakistan's second innings for 359 before Sri Lanka knocked off the meager 137-run target for one wicket. (Agencies)
In achieving the victory, Sri Lanka also defied the cloudy weather in Dubai and rain forecast for later Sunday.
Opener Dimuth Karunaratne (62 not out) hit the winning runs after putting on 124 for the first wicket with Kaushal Silva who fell after scoring 58.
Kumar Sangakkara remained unbeaten on nine. Pakistan's lowest defended target was 127 achieved against New Zealand at Hamilton in 1993, when they dismissed their opponents for 93 but Sri Lanka ensured the good work was not lost.
Sri Lanka had previously beaten Pakistan by eight wickets on two occasions in 45 Tests between the two nations. In a surprise move Pakistan opened the bowling with off-spinner Mohammad Hafeez but both openers played with authority.
Silva hit five boundaries before trapped leg-before by Saeed Ajmal. Karunaratne hit eight boundaries off 125 balls.
Ajmal was once again ineffective, having now taken five wickets in two matches.
Pakistan will be desperate to level the series in the third Test starting in Sharjah from Thursday to avoid their first-ever series defeat in United Arab Emirates, their adopted base for cricket since 2010 because of security fears back home.
The first Test ended in a draw in Abu Dhabi.
Earlier, Pakistan failed to prolong their resistance of the fourth day as they lost three wickets in the space of just 29 runs.
Lakmal removed Sarfraz Ahmed in the fourth over of the day, bringing one in sharply to beat the Pakistani's forward defensive push and hit the off-stump. Sarfraz scored 74, batting for 211 minutes and hitting seven boundaries in a fighting innings that took the game to the final day.
Lakmal then had Rahat Ali caught behind for eight, for Prasanna Jayawardene's ninth catch in the match. Prasanna equalled Sri Lanka's record of nine catches by a wicketkeeper in a match set twice in successive Tests by Amal Silva against India at home in 1985.
Lakmal bowled Ajmal (21) to end Pakistan's second innings. Lakmal's previous best was 3-55 against Australia at Galle in 2011.
Nuwan Pradeep, Shaminda Eranga and Rangana Herath took two wickets apiece.
Sri Lankan paceman bowled well on the first day to get Pakistan out for a low score of 165 and then gained a big 223-run lead with experienced batsman Mahela Jayawardene hitting a brilliant 129.
Pakistan did put up a fight, taking the game to the final day with skipper Misbah-ul Haq hitting 97 and Younis Khan scoring 77 on the fourth day but the first-innings deficit led to their downfall.
Paceman Suranga Lakmal took all three wickets to fall on the fifth morning to finish with a career-best 4-78 to wrap up Pakistan's second innings for 359 before Sri Lanka knocked off the meager 137-run target for one wicket.