Mair got a loose puck and skated to the net around Kristopher Letang in the left circle, sneaking a shot past goalie Jocelyn Thibault on the short side just before taking a big hit from Noah Welch.
Maxim Afinogenov had tied the game with 5:52 to play in the third period on the Sabres' second short-handed goal of the game, skating around Ryan Whitney between the circles and then avoiding a sliding Brooks Orpik to score his first goal of the preseason.
The Penguins (2-1-3) and Sabres (4-1-0) meet again Saturday night in Buffalo.
The Penguins built a 2-1 lead after two periods. Colby Armstrong's goal at 7:27 of the first period made it 1-0, and after Daniel Briere tied it on a power-play goal at 14:04 of the second, John LeClair put Pittsburgh ahead by skating down the right wing and beating Martin Biron.
Teppo Numminen's short-handed goal 30 seconds into the third period tied the game, but Armstrong scored his second goal with 8:34 to play to give the Penguins a 3-2 lead, taking a cross-ice pass from Whitney to beat Biron from the left circle.
Linemate Sidney Crosby picked up his second assist of the game on the play and has nine points in four preseason games.