Sohaib Maqsood and Fawad Alam put on a 147-run stand as Pakistan recovered from the brink to defeat Sri Lanka by four wickets on Saturday and take the lead in the three-match one-day international series.
The tourists, chasing a Duckworth-Lewis target of 275 in 45 overs, fought back after being 106-5 to scrape home off the penultimate ball of the match in Hambantota.
Maqsood remained unbeaten on a glorious 89 off 73 balls as Shahid Afridi smashed the winning boundary off seamer Nuwan Kulasekara to the point fence.
Alam was dismissed for 62 by Lasith Malinga when 22 still remained for victory off the last three overs, but Maqsood and Afridi battled on to help Pakistan record a good win.
Sri Lanka had made 275-7 after being sent in to bat in overcast conditions, but rain after six overs of their innings reduced the game from a full 50-overs-a-side contest to 45.
Opener Ahmed Shehzad scored 49 but no other top-order batsman settled in to make a big score till Maqsood and Alam turned the game Pakistan's way.
Jayawardene, 37, who retired from Tests earlier this week to concentrate on one-day cricket till next year's World Cup, hit eight boundaries in his 73rd half-century in the shorter format.
Sri Lanka slumped to 75-4 by the 18th over before Jayawardene and Mathews put on 116 for the fifth wicket.
Mathews hit nine fours in his best score in one-day cricket, but it was Ashan Priyanjan's unbeaten 39 off 15 balls at the end that bossted the total.
Lanky left-arm fast bowler Mohammad Irfan, who stands at seven feet, one inch (2.16 metres), generated good bounce from the moisture-laden pitch to claim two wickets for 48 runs.
Wahab Riaz, one of the three left-arm seamers for Pakistan alongside Irfan and Junaid Khan, took three for 50.
The tourists were without their top spinner Saeed Ajmal, who has flown to Australia to undergo tests of his bowling action.
Meanwhile, Hambantota will also host the second one-dayer on Tuesday due to bad weather in Colombo, the original venue.