SAN DIEGO -- Pablo Sandoval homered, and the San Francisco Giants snapped a four-game losing streak with a 4-2 victory over the San Diego Padres at Petco Park on Thursday night.
The Giants (41-50) won for only the second time in their last 12 road games and handed the Padres (41-52) their 12th setback in 13 games.
Madison Bumgarner allowed two runs on three hits in the first inning but limited the Padres to one hit over the next six innings. Bumgarner (10-5), who is headed to next week's All-Star game, held the Padres to four hits overall with six strikeouts and a walk, which was intentional, in seven innings.
Reliever Sandy Rosario pitched a scoreless eighth before closer Sergio Romo converted his 20th save by retiring the side in order in the ninth.
Luke Gregerson (4-5) gave up two runs and three hits in the eighth, when the Giants broke a 2-2 tie.
Gregor Blanco's ground-rule double to left with one out in the eighth gave the Giants a 3-2 lead. Buster Posey added an RBI single with two outs in the inning.
Kensuke Tanaka's single to center scored Sandoval to tie the score at 2 with one out in the sixth. It also chased Padres starter Jason Marquis, who struggled with his command in the inning before being lifted by manager Bud Black.
After striking out Posey to lead off the sixth, Marquis walked Sandoval and then gave up a single to Hunter Pence. A walk to Brandon Belt loaded the bases before Tanaka delivered his RBI hit.
Marquis threw 96 pitches (55 for strikes) in 5 1/3 innings, allowing two runs on seven hits with two walks and three strikeouts. It marked the fifth consecutive outing Marquis received a no-decision.
In the first inning, Carlos Quentin gave the Padres a 1-0 lead with an RBI double off Bumgarner to left-center, scoring Chris Denorfia. After an intentional walk to Jesus Guzman, Kyle Blanks followed with a groundout that scored Chase Headley for a 2-0 Padres advantage.
Sandoval led off the third by driving a 2-2 Marquis pitch into the seats in right to cut the lead in half.
NOTES: Giants RHP George Kontos began serving his three-game suspension Thursday stemming from a June 11 incident with Andrew McCutchen, when the reliever hit the Pirates star with a pitch. Kontos will be eligible to return for Sunday's series finale at San Diego. ... San Francisco RHP Jean Machi was recalled from Triple-A Fresno on Thursday. The Giants sent down LHP Mike Kickham to Fresno on Wednesday. ... Padres 1B Yonder Alonso is expected to return to the starting lineup for Friday's game against the Giants. Alonso has been on the disabled list since June 6 with a fractured right hand. ... Giants RHP Ryan Vogelsong had a bullpen session Thursday that manager Bruce Bochy described as successful. Vogelsong, who threw about 30 pitches, has been on the disabled list since May 21 with a fractured right hand. There is no timetable for his return. ... The game drew a crowd of 31,976.