Chandimal finished with 64 not out off 70 balls and added a match-turning 40 runs for the ninth wicket with Ajantha Mandis (19 not out) to see Sri Lanka through with two balls to spare. Mendis hit the winning boundary and smashed one of the two sixes in Umar Gul's penultimate over which cost Pakistan 15 runs and the match.
Chandimal hit his only boundary to reach fifty before hitting a six off Gul to clinch an unlikely win after Sri Lanka had wobbled at 195-8, derailed by Junaid Khan (3-31) and Saeed Ajmal (2-43). Sri Lanka, who chased down a 285-run target in their second one-day win in Dubai, were cruising along at 113-1 after Kusal Perera (47) and Tillakaratne Dilshan (45) gave them a brisk start of 75. Perera was aggressive right from the word go, hitting four sixes and three boundaries in his 40-ball knock, but was trapped leg-before by Mohammad Hafeez after he attempted a reverse sweep.
When on 31, Dilshan completed 8,000 one-day runs, becoming the sixth Sri Lankan to achieve the milestone. But Sri Lanka then lost three quick wickets in the space of just 24 runs, two of those to Junaid. Junaid had Dilshan caught behind and bowled Kumar Sangakkara (22) round his legs to complete 50 wickets in the calendar year.
Gul accounted for Ashan Priyanjan (one) while skipper Angelo Mathews's laborious 31-ball eight was ended by paceman Anwar Ali before Chandimal's rearguard action.
Earlier, Pakistan captain Misbah-ul Haq top-scored with 51 while in-form batsman Hafeez, who scored three centuries in the series, made 41 as Pakistan were bowled out for 232 in the 50th over. Anwar Ali chipped in with a fiery 38-ball 41 not out spiced with one six and two fours.
Pakistan found the going tough after openers Ahmed Shehzad (17) and Sharjeel Khan (18) by 13th over.
Lasith Malinga made it 70-3 by dismissing Sohaib Maqsood (seven) before Misbah and Hafeez shared a 58-run stand for the fourth wicket before the innings once again was derailed.
Hafeez was bowled by Angelo Mathews after his 56-ball knock with two boundaries. He finished the series with 448 runs with three hundreds.
Malinga then came into his own, sending Misbah back caught behind and then trapped Abdul Rehman (one) to leave Pakistan struggling at 176-7. Malinga finished with 4-57.
Misbah hit two boundaries and a six during his 74-ball knock, finishing with 1,371 runs in 34 one-day matches this year -- the most by any player.
The two teams now play a three-match Test series, with the first in Abu Dhabi from December 31.
Photos: 'Dangal' girls Sanya Malhotra, Fatima Sana Shaikh's dinner outing
Photos: Salman Khan, Daisy Shah spotted at the Mumbai airport
Photos: Rakhi Sawant to play Honeypreet in Ram Rahim biopic
Photos: Arvind Kejriwal asks Kamal Haasan to join politics
Photos: TV actress who played goddesses on the small screen