The hosts, needing 99 to win in a minimum of 21 overs, beat fading light and approaching rain to cruise home in the 17th over in front of some 5,000 jubilant home fans.
Jayawardene, who is due to retire from Test cricket after the two-match series, scored 26 before Kumar Sangakkara (21) and skipper Angelo Mathews (25 not out) chipped in lower down the order.
Mathews and Kithuruwan Vithanage smashed 17 runs in the 16th over bowled by Junaid Khan and then scored the winning run in the next over just before rain hit Galle.
The win was set up by left-arm spinner Rangana Herath, who claimed six for 48 that bundled Pakistan out for 180 in their second innings in the post-tea session.
Pakistan, who started the day at 4-1, lost three wickets in the morning session to go to lunch on 66-4.
The tourists added eight runs in the morning when seamer Dhammika Prasad had nightwatchman Saeed Ajmal edging a catch to wicket-keeper Niroshan Dickwella.
Opener Ahmed Shehzad made 16 when he was given out leg-before to off-spinner Dilruwan Perera to make it 39-3.
Shehzad, who consulted his partner Azhar Ali before deciding not to ask for an umpire's review, would have survived if he had signalled for it. Television replays showed the ball missing the leg stump.
Herath dealt Pakistan a bigger blow when he bowled first innings century-maker Younis Khan for 13 to reduce the tourists to 55-4.
Ali and skipper Misbah-ul Haq put on 56 for the fifth wicket on either side of lunch when both fell at the same total to make it 111-6 -- just 29 runs ahead with 45 overs left in the game.
Ali (41) was caught behind off Herath and Misbah (28) was leg-before to Perera in the next over.
Pakistan found themselves pinned against the wall at 133-7 when Asad Shafiq, the last recognised batsman, was leg-before to Herath for eight.
Seamer Shaminda Eranga had Abdur Rehman caught behind at the stroke of tea before Herath dismissed Mohammad Talha and last man Junaid to leave gutsy Sarfraz Ahmed stranded on 52 not out.
The second and final Test will be played at the Sinhalese Sports Club in Colombo from Thursday.
COMMENTS (9)
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ
A slap on experts like Rameez and Yousuf who predicted if Pakistan could score more than 400 runs on this pitch then they can win this match.
Nothing new.
Congratulations Najam Sethi!
India and Pakistan always compete with each other; this time which team has lost more shamefully!!
We depend on climate or on our batsmen for winning the match?
My word... Punjab police containers have a bigger heart for a fight than pakistan cricket team!!
Unbelievable !!!!
Pakistan always follow India.
bad