Buster Posey hit a tie-breaking sacrifice fly in the bottom of the eighth inning, and the San Francisco Giants went on to beat the Arizona Diamondbacks, 3-1, at AT&T Park.
Arizona reliever Bryan Shaw (1-3) walked Ryan Theriot to start the eighth and Melky Cabrera set a record by following with his third hit of the game, a single to right field.
Cabrera upped his hit total this month to 50, breaking Willie Mays' 1958 mark for the most in the month of May in the San Francisco era.
"It's been a treat to watch him day in and day out," Giants manager Bruce Bochy said about Cabrera.
Posey, who doubled home Cabrera with the tying run two innings earlier, put the Giants on top by sending Shaw's offering to right.
Joaquin Arias plated an insurance run by grounding into a 4-6 fielder's choice with the bases loaded.
"You gotta tip your cap to them," said Arizona manager Kirk Gibson. "They executed."
Santiago Casilla earned his 14th save of the season with a flawless ninth.
Cabrera, Posey (two) and Angel Pagan (two) accounted for San Francisco's seven hits.
Giants starter Ryan Vogelsong escaped a pair of bases-loaded jams while pitching seven innings. He gave up six hits, including an RBI single by Arizona's Josh Bell in the second, walked three and struck out eight.
The late offensive burst made a winner out of Clay Hensley (2-3).
Diamondbacks left-hander Joe Saunders held the Giants to one run on five hits over 5 1/3 innings.
Randy Winn (51 in September 2005) holds the record for the most hits in a single month in the San Francisco era...The Giants have won four straight over the Diamondbacks after dropping the previous nine meetings...No Arizona player had more than one hit...Saunders remains winless (0-4) in six career starts against the Giants...The Diamondbacks were 2-for-9 with runners in scoring position and stranded nine.