MILWAUKEE -

Pablo Sandoval homered and drove in three runs as the San Francisco Giants defeated the Milwaukee Brewers 7-4 at Miller Park Wednesday night.

Sandoval opened the scoring in the first inning with a run-scoring single off Brewers starting pitcher Yovani Gallardo.

Michael Morse followed with a two-run single to put the Giants ahead 3-0.

Carlos Gomez hit his 17th homer of the season in the bottom of the first to cut the lead to 3-1.

After Morse drove in another run in the top of the fourth, the Brewers rallied in the seventh behind a two-run single by Aramis Ramirez to make it a 4-3 game.

But Sandoval hit a two-run homer off Brandon Kintlzer in the eighth to seal the win.

Gallardo (6-6) gave up nine hits, four walks and four earned runs in his four innings of work.

Ryan Vogelsong (7-6) got the win for the Giants pitching six innings allowing seven hits and one earned run.

Khris Davis hit his 18th home run of the season in the ninth inning for Milwaukee.