Hafeez finished with 80 not out for his ninth Test half-century, his first in 11 innings, while Ahmed Shehzad notched his maiden fifty on his debut as Pakistan, set 302 runs in a possible of 67 overs, finished on 158-2.
The draw left the three-Test series open, with the second Test starting in Dubai on Wednesday. The third Test will be played in Sharjah from January 16.
The no-result is also a moral victory for the Sri Lankans who were in a danger of losing after conceding a big 179-run lead in the first innings and were 186-4 after the third day, leading by just seven runs with six wickets intact.
Sri Lankan skipper Angelo Mathews hit a career-best 157 not out to pull his team out of danger on the fourth day when they lost only one wicket in the full day´s play for 234 runs.
The target always looked beyond Pakistan´s reach as their best winning chase in all Test cricket was 314 against Australia in Karachi in 1994.
Pakistan lost opener Khurram Manzoor early, caught behind off paceman Suranga Lakmal after scoring eight, but Hafeez and Shehzad avoided any further loss and put on 94 in an unbroken second wicket stand.
Hafeez reached his half-century with two fours in one Sachitra Senanayake over. He had been dropped from the Pakistan team for the two-Test series against South Africa, also in Abu Dhabi, in October, after scoring just 113 in 11 innings.
Shehzad also hit spinner Rangana Herath for his seventh four to reach his maiden 50 before he was trapped leg-before by the same bowler soon after tea for 55.Hafeez hit 11 fours during his sedate knock. Younis Khan was the other unbeaten batsman with 13.
Earlier, Sri Lanka declared their second innings on 480-5 after batting an hour and 30 minutes but their slow batting showed they had saftey on their minds rather than forcing a lead in the three-Test series.
It was the unfinished sixth wicket 156-run stand between Mathews and Prasanna Jayawardene (63 not out) that continued on the fifth day and ended all hopes of a Pakistani win.
Mathews batted for 457 minutes, hit 16 fours and a six in an extraordinary display of patience and fight.Prasanna´s 169-ball knock had six fours and a six.Pacemen Junaid Khan finished with 3-93, while Bilawal Bhatti took 2-146.Off-spinner Saeed Ajmal, who took 18 wickets in Pakistan´s 1-0 win over Sri Lanka in 2011, finished wicket-less in his 49 overs, conceding 115 runs — only the fifth time that he failed to get a wicket in an innings in his 31 Tests.