Trailing 2-0 entering the frame, the first-place Padres scored five times to put the game away and cruise to their eighth win in 10 games.
After pitcher Wade LeBlanc (5-8) and Jerry Hairston Jr. got one-out singles, Chris Denorfia drove in both with a double to tie the contest. Gonzalez then followed by driving a pitch over the right field wall for his 21st homer.
Will Venable's RBI single completed the rally.
LeBlanc allowed three runs on eight hits in a six-inning start, walking none and striking out two.
Brad Lincoln (1-4) took the loss for the Pirates, surrendering six runs on eight hits over the course of 6 1/3 innings.
Ronny Cedeno smacked a two-run homer for Pittsburgh.