Malik frustrated Sri Lanka's bowlers during the first two sessions of the final day as Pakistan reached the tea interval on 233 for three, needing to bat out another 30 overs to save the game.
Middle order batsman Faisal Iqbal (60) provided solid support during a 115-run third wicket partnership spanning 193 minutes.
Skipper Inzamam-ul-Haq also provided resistance with 30 not out.
Starting the day on 89 for two needing an improbable 369 for victory, Pakistan's cause was helped by an 81-minute interruption due to bad light and drizzle during the morning.
Malik and Iqbal survived the morning and early afternoon without major alarm on a pitch that has grown increasing placid during the course of the match.
Even star off-spinner Muttiah Muralitharan was handled with relative ease and skipper Mahela Jayawardene used seven bowlers to try and conjure up a breakthrough.
The hosts finally found success with the second new ball, which was taken immediately it became available with the score 179 for two.
All rounder Farveez Maharoof, Sri Lanka's best bowler in the game, nipped a delivery back to trap Iqbal lbw.
Malik, dropped on 14 the previous evening, should also have been given out lbw on 70 after a missing a full-length Maharoof inswinger.
Sri Lanka had declared just before tea on day four after piling up 448 for five in their second innings after Kumar Sangakkara scored a fine 185.
The second and final test starts in Kandy on Monday.