The Padres maintained a 2 1/2-game lead over second-place San Francisco in the National League West.
San Diego claimed a 7-0 advantage through six innings, thanks in part to Hairston's two-run homer in the sixth. Gonzalez had an RBI double in the fifth and a run-scoring single in the sixth, and scored a run in the fourth on a wild pitch.
Pittsburgh got back in the game with a four-run seventh, with Ryan Doumit driving in two of the runs on a double.
Kevin Correia (9-7) lasted 6 1/3 innings to get the win. He was charged with all four runs in the seventh to go along with four hits and seven strikeouts.
Heath Bell worked a 1-2-3 ninth to get his 33rd save.
James McDonald (1-2) absorbed the loss, giving up four runs on seven hits in 4 2/3 innings.
Notable deaths of 2014 [PHOTOS]