PHOENIX -- Everything was working for Madison Bumgarner.
"I feel like I got better as the game went on," Bumgarner said. "We were making pitches both sides of the plate, the ball down when we wanted to go down and when we wanted to go up. I felt pretty good all-around today."
When Bumgarner took the mound for the ninth, the only hit he had allowed was an infield single that easily could have been an out.
"I'm not going to lie. I thought about it," Giants manager Bruce Bochy said. "That would have been a tough only hit to give up."
Another infield hit ended Bumgarner's outstanding day. He was charged with an unearned run to go along with seven strikeouts and two walks.
"He was exceptional," Diamondbacks manager Kirk Gibson said. "Maybe the best I have ever seen him."
Sergio Romo gave up Martin Prado's RBI single but got his second save in two nights and his 22nd in 26 opportunities overall.
Cody Ross got Arizona's first hit when he reached on a dribbler to the left of the mound in the second. Bumgarner went to his right to get the ball, slid, and then stood up and threw low to first baseman Joaquin Arias.
"I just tried to get to it as soon as I could," Bumgarner said. "I thought sliding and picking it up and standing up would be the quickest to do it. I didn't want to air-mail it to Arias over there. I kind of threw it in the dirt and gave him a tough hop to get. Nine times out of 10 he comes up with that."
Arizona's Paul Goldschmidt called it "one of the better performances I've seen."
Diamondbacks rookie Mike Bolsinger (1-3) allowed a run and five hits in 7 2-3 innings.
"He is good and that is why he will probably be an All-Star again this year," Bolsinger said of Bumgarner. "All I could do is really keep the team in the game. I tried to and we just caught Bumgarner on one of his good days."
San Francisco won two in a row against Arizona after losing six straight. It was the third victory in the last 12 games for the NL West-leading Giants, who play the next 10 at home.
"It was time for us to start working our way out of this," Bumgarner said. "Everybody's still been in good spirits, a good attitude, so that's a big series to win for us."
San Francisco led 1-0 through eight innings. The run scored when Tyler Colvin doubled home Brandon Crawford from first in the fifth inning. Colvin was out trying to stretch it to a triple on a superb relay throw by shortstop Didi Gregorius.
San Francisco tagged on three in the ninth, including Joe Panik's run-scoring double for his first career RBI in his first major league start. Buster Posey also doubled home a run and Crawford had an RBI single.
In the Arizona ninth, pinch-hitter Jordan Pacheco reached on an error by shortstop Crawford and Ender Inciarte singled off the glove of third baseman Pablo Sandoval. Bochy then pulled Bumgarner, who was trying for his third career complete game.
The Giants have decided not to put OF Angel Pagan on the DL, at least for now. He has missed the last six games with back problems. ... San Francisco returns home to face San Diego on Monday in the opener of a 10-game homestand. Matt Cain (1-5, 4.52 ERA) goes for San Francisco against Andrew Cashner (2-6, 2.46 ERA). ... The Diamondbacks have Monday off and begin a two-game interleague series against Cleveland on Tuesday. ... Diamondbacks rookie SS Chris Owings missed his second straight game with a sore ankle.