Bairstow's unbeaten 108 off 48 balls, with eight fours and nine sixes, see Punjab secure the win with eight balls to spare
Sri Lanka, who had conceded a 109-run lead, were bowled out for 113 in their second innings as Nathan Lyon (4-31) wrecked their top order and part-timer Travis Head (4-10) polished off the tail.
Needing only five runs to win, opener David Warner hit Ramesh Mendis for a four and followed it with a six to seal Australia's victory in four deliveries.
Galle also hosts the second Test from Friday.