Updated

Brandon Belt ripped a tie-breaking, two-run single in the top of the eighth inning to lift the San Francisco Giants to a 6-4 victory over the Arizona Diamondbacks on Monday in the opener of a three- game set at Chase Field.

Belt also smacked a solo shot in the second, while Pablo Sandoval and Gregor Blanco added an RBI and a run scored apiece to help the Giants snap a five- game slide that started with back-to-back, extra-inning losses against Arizona.

Jean Machi (1-0) earned his first major league victory after pitching a perfect seventh in relief of starter Matt Cain, who remains in search of his first victory of the season after giving up four runs on five hits and four walks over six frames.

Sergio Romo worked around a leadoff single in the ninth to nail down his ninth save of the season.

Brad Ziegler (0-1) entered for Arizona starter Ian Kennedy to start the eighth and served up Belt's go-ahead single to absorb the loss. Kennedy allowed four runs on seven hits and three walks over seven innings.

"It's just one of those days," Kennedy said. "You give your team a chance to win and we just didn't."

All four of Arizona's runs came in the fourth, as Jason Kubel, Eric Chavez and Martin Prado each homered in the frame, but it wasn't enough for the Diamondbacks, who had won five of their last six coming into the contest.

With the game locked at 4-4 to start the eighth, Nick Noonan smacked a leadoff double before moving to third on Buster Posey's fly out.

Ziegler then got Hunter Pence to ground out, but issued back-to-back walks to Blanco and Brandon Crawford to load the bases for Belt, who smacked a 3-1 sinker back up the middle to plate a pair and give the Giants the lead.

Javier Lopez and Santiago Casilla combined to blank the Diamondbacks in the bottom half before Romo shut the door in the ninth.

The Giants broke through in their first at bat, as Marco Scutaro and Sandoval smacked back-to-back one-out singles before Posey walked to load the bases.

Scutaro scored on Pence's sacrifice fly before Sandoval crossed the plate on Blanco's single to left for a 2-0 lead.

Belt's leadoff blast in the second pushed the margin to 3-0, but Arizona clubbed a trio of homers off Cain in the fourth to jump in front.

After Cody Ross worked a leadoff walk, Kubel belted a first-pitch fastball over the wall in right-center field. Chavez then followed with an opposite- field blast to left to tie the game before Prado pounded a two-out solo shot to left-center field to give Arizona a 4-3 lead.

"As a pitcher, you're pissed that you give up the lead," Cain said. "It lifts you up big time when the guys come back out there and score another run the next inning."

The Giants countered with a run in the fifth to tie the game, as Scutaro stroked a one-out single and moved to second on a wild pitch before scoring on Sandoval's base hit to center to make it 4-4.

Game Notes

San Francisco manager Bruce Bochy was ejected in the top of the fifth inning after arguing a play at first base ... Sandoval left the game in the seventh with right elbow discomfort ... Posey extended his hitting streak to 10 games ... Arizona outfielder Gerardo Parra went 0-for-5 to snap his career-high 13- game hitting streak ... The Giants had gone winless in Cain's last six starts dating back to last season, with their last win coming against Arizona on Sept. 26 ... Cain allowed three home runs in an inning for the first time in his career.