Opener Imam-ul-Haq anchored Pakistan's nervy chase with an unbeaten half-century as they beat Sri Lanka by four wickets in the opening Test in Galle on Thursday.
Chasing 131 for victory, Pakistan slumped to 79-4 after skipper Babar Azam fell to left-arm spinner Prabath Jayasuriya, who claimed 4-56 in the second innings.
Imam combined with Saud Shakeel to steady the ship but Sri Lanka refused to throw in the towel despite not having enough runs to defend.
Shakeel, who made a career-best 208 not out in the first innings, fell for 30 and Sarfaraz Ahmed (one) did not last long either.
Imam remained unbeaten on 50 watched from the other end as Agha Salman secured Pakistan's victory in style hitting the first ball he faced, from Jayasuriya, over the mid-off boundary.
Shakeel, whose maiden Test double hundred fetched Pakistan a decisive first-innings lead of 149, was adjudged Player of the Match.
"The way Saud and Agha played, it totally changed the game," Babar said referring to their 177-run partnership, which helped Pakistan post 461 in the first innings.
"It's not easy to bat in Galle, but the way Saud's playing is outstanding."
Sri Lanka's top order could not vindicate their decision to bat first and they reached 312 in their first innings courtesy Dhananjaya de Silva's gallant 122.
"We needed to see off that opening spell but we lost a few wickets," home captain Dimuth Karunaratne said.
"Overall, the bowlers did well, but we dropped a few catches and that cost us. We have to assess what went wrong and come back again."
The teams move to Colombo for the second and final Test beginning on Monday.