Bairstow's unbeaten 108 off 48 balls, with eight fours and nine sixes, see Punjab secure the win with eight balls to spare
Azhar shared an opening partnership of 215 with Sami Aslam, who was bowled by Roston Chase for 90 in the final session to give the Caribbean side their only success of the day.
In only the second ever day-night Test match, Pakistan captain Misbah-ul-Haq elected to bat after winning the toss and the West Indies bowlers struggled to get the pink ball to move in the air or off the pitch.
Asad Shafiq was unbeaten on 33 at the close alongside Azhar, who hit 14 fours in his 11th Test century.