SAN FRANCISCO — Jhoulys Chacin outpitched Madison Bumgarner, Cory Spangenberg hit a go-ahead two-run homer in the seventh inning that chased MadBum from his first home start in more than three months and the San Diego Padres beat the San Francisco Giants 5-2 on Thursday night.

Bumgarner (0-4) struck out five and walked one over 6⅓ innings, taking his home mound for the first time since spraining his pitching shoulder in an April 20 dirt bike accident. The 2014 World Series MVP is winless after six 2017 starts.

Hunter Renfroe came off the disabled list and hit an early two-run homer to help back Chacin’s third consecutive winning decision. Wil Myers added a run-scoring double in the eighth as San Diego bounced back from an embarrassing 18-4 rout by the Rockies on Wednesday at Coors Field.

Chacin (9-7) allowed two runs on four hits, struck out four and walked one in six innings.

Bumgarner received a warm welcome in his return, then went 1-2-3 in the first on 11 pitches, a pair of flyball outs to left and a strikeout. Then he surrendered a leadoff double to Jabari Blash to start the second, followed by Renfroe’s homer just inside the left-field foul pole.

The left-hander and 2014 World Series MVP pitched at AT&T Park for the first time since April 13. Bumgarner also allowed two home runs Saturday, so this marked the first time in his career he has surrendered multiple longballs in consecutive outings during a single season.

San Francisco fell to 0-6 in his starts, having given the ace just 10 runs of support.

The Giants wasted Denard Span’s leadoff double in the fourth, stranding him at third with three outs in a row after his hit. Span hit an RBI single the next inning that scored Gorkys Hernandez, aboard on a base hit. Eduardo Nunez singled home Span to tie the game at 2.

San Francisco loaded the bases against Brad Hand with two out in the eighth, but Buster Posey flied out to right.

Brandon Maurer allowed two singles in the ninth but finished for his 20th save. San Diego has won 15 of the last 20 meetings in the rivalry dating to last year’s All-Star break.