Mathews stars in Sri Lanka's series-clinching win
Mathews smashed two sixes and four boundaries in his 76-ball knock to help his team achieve a 248-run target with two balls to spare in the day-night match.
Sri Lanka needed 15 runs to win in the last over bowled by paceman Mohammad Sami before Mathews completed the win with a four.
Dinesh Chandimal was the other main scorer for Sri Lanka with 54.
Paceman Sohail Tanvir bagged three wickets and leg-spinner Shahid Afridi two to reduce Sri Lanka to 138-6 before Mathews received valuable support from Jeevan Mendis (19) and Nuwan Kulasekara (10 not out) to steer his team home.
Afridi removed well-set Kumar Sangakkara (40) and skipper Mahela Jayawardene off successive balls to put pressure on Sri Lanka.
Sangakkara, who was dropped on 25 by wicket-keeper Sarfraz Ahmed off Sami, failed to capitalise on the chance as he could add 15 more runs.
Ahmed made amends when he smartly stumped Sangakkara off Afridi, who then held a return catch off his next ball to dismiss Jayawardene.
Tanvir jolted Sri Lanka when he removed openers Tillakaratne Dilshan and Upul Tharanga, but Sangakkara and Chandimal put on 78 for the third wicket.
Pakistan's opener Imran Farhat, playing his first one-dayer in four months, earlier cracked an impressive 56 and Umar Akmal an unbeaten 55.
Pakistan batted steadily after losing out-of-form opener Mohammad Hafeez (six), with Azhar Ali (30) and Farhat adding 60 for the second wicket and then Akmal putting on 61 for the fifth wicket with skipper Misbah-ul-Haq (32).
Akmal smashed two sixes and five fours in a 61-ball knock for his 15th half-century in one-dayers.
Hafeez, who was bowled by paceman Kulasekara, scored just 20 runs in his last four one-dayers.
Farhat dominated the Sri Lankan attack in the initial overs, twice hitting Kulasekara for three fours in an over.
He fell pulling seamer Thisara Perera to deep mid-wicket where he was caught by Chandimal after smashing nine fours in his 12th half-century in one-day internationals.
Leg-spinner Mendis, playing his first match of the series, was the most impressive bowler with 2-30 while Kulasekara finished with 2-53.
Sri Lanka made one change from the team which won the last match by 44 runs on Saturday, replacing Sajeewa Weerakoon with Mendis.
Pakistan brought in Farhat and Sami in place of Younis Khan and off-spinner Saeed Ajmal.
Sri Lanka and Pakistan will now play a three-Test series, starting in Galle on Friday.
election 2014: latest
Sachin Tendulkar announced his retirement from international cricket after playing his 200th Test in the home series against the West Indies next month.
Date 09-10-13, Duration 0:40, Views 22378