Upul Tharanga scored a painstaking unbeaten 112 and added a crucial 76 runs for the 8th wicket with Vandersay, but failed to taken Sri Lanka to victory in the 2nd ODI at Abu Dhabi.
Vandersay made 22.
It was Sri Lanka's 9th consecutive ODI loss.
Sri Lanka was on top in the first quarter of the match, having reduced Pakistan to 101 for 6, before Azam and Shadab put together a gritty 109-run stand to propel Pakistan to 219.
One-drop batsman Babar knocked a fighting 133-ball 103 while Shadab scored a career-best 52 not out to lift Pakistan from a struggling 101 for 6 before Shadab the bowler returned with his best figures of 3 for 47 to dismiss Sri Lanka for 187 all out in 48 overs.
It was Azam's second consecutive 100 in the series and the 5th consecutive ODI century at the UAE.
The victory gives Pakistan a 2 nil lead in the five-match series.