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.
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.
Also Read
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.
Hafeez hit 11 fours during his sedate knock. Younis Khan was the other unbeaten batsman with 13.