Los Angeles celebrated earlier in the day when Arizona lost to St. Louis, and the Dodgers clinched the National League West title.
San Diego kept Los Angeles from making it a perfect day by jumping to an early lead and holding on in its bid to avoid the worst record in the National League. The Padres have a 2 ½-game lead over Washington heading into the final three games of the season.
Giles hit a two-run homer in the first inning and Gonzalez had a solo shot in the sixth to give the Padres a 5-3 lead. Will Venable added an RBI single in the fifth and a sacrifice fly in the ninth.
Jake Peavy (10-11) got the win by surviving five innings while giving up three runs on four hits.
Trevor Hoffman picked up his 29th save.
The loss went to Eric Stults (2-3), who surrendered three earned runs over 4 2/3 innings.