Hafeez finished with 113 not out for his ninth one-day hundred as Pakistan knocked off their modest 226-run target in the 42nd over to take an unbeatable 3-1 lead ahead of Friday’s fifth and final match.
Pakistan had restricted Sri Lanka to 225 all out in 48.5 overs with Ajmal (4-39) and paceman Umar Gul (3-37) sharing the spoils.
Hafeez, who hit hundreds in Pakistan’s two wins in the first and third matches in Sharjah, pushed Tillakaratne Dilshan for his 12th boundary to complete three figures, raising his bat and blowing a kiss to his wife in the stands.
Hafeez became the sixth batsman in all one-day cricket to hit three tons in one bilateral series.
In all Hafeez hit two sixes and 12 boundaries off 119 balls, while Sohaib Maqsood finished with a 56-ball 46 not out with a six and four boundaries.
Hafeez and Ahmed Shehzad (44) put Pakistan on track during a solid 84-run stand after opener Sharjeel Khan was dismissed for 13.
Shehzad, who hit a career best 124 in Pakistan’s two-wicket loss in the second match in Dubai, started off well with three boundaries in Nuwan Kulasekara’s third over while Hafeez matched his partner with as many boundaries in Suranga Lakmal’s seventh.
The stand set up victory and even after Shehzad’s dismissal, caught in the slips off Lakmal, Pakistan wiped off the target with consummate ease.
Shehzad hit five boundaries during his 56-ball knock as Sri Lanka’s bowlers were rendered ineffective.
Maqsood and Hafeez shared an unbroken 111-run stand for the third wicket.
This becomes Pakistan’s seventh one-day series win in the year, their best-ever in a calendar year, beating the six series win record achieved in 2011.
Earlier, Sri Lanka failed to post a big total after Angelo Mathews opted to bat after winning the toss on a flat Sheikh Zayed Stadium pitch.
Gul removed openers Kusal Perera (eight), Tillakaratne Dilshan (eight) and Dinesh Chandimal (five) to reduce Sri Lanka to 36-3 before Ajmal tightened the screws at the end of the innings.
Ashan Priyanjan fought hard during his 93-ball 74, which included ten boundaries, to register the highest score for a one-day debutant for Sri Lanka, beating Chamara Silva’s 55 made against Australia in Colombo in 1999.
Priyanjan shared two useful stands of 89 with Kumar Sangakkara (51) for the fourth wicket and then added another 40 with skipper Angelo Mathews (38) to keep Sri Lanka on course for a respectable total.
But Sangakkara’s run out, off a brilliant piece of fielding by substitute fielder Anwar Ali at point, derailed Sri Lanka. Sangakkara had looked good duing his 78-ball knock, featuring three boundaries.
Priyanjan had looked solid until he tried an unusual shot off paceman Junaid Khan and was bowled just three balls into the batting power-play.
Ajmal then bowled Nuwan Kulasekara (one), trapped a dangerous looking Mathews and Sachitra Senanayake (nought).
Kithuruwan Vithanage chipped in with a useful 27 before he became one of Junaid’s two wickets.
After the conclusion of the one-day series, Pakistan and Sri Lanka will play three Tests, starting in Abu Dhabi on December 31.