Giants pitcher Madison Bumgarner retired the first 23 batters he faced before finishing with a one-hit shutout as San Francisco defeated the San Diego Padres 8-0.
Angel Pagan and Brandon Belt hit solo homers for San Francisco and Marlon Byrd drove in three runs as the Giants (74-68) continued to chase NL West leaders the Los Angeles Dodgers.
But the star of the show was last year's World Series Most Valuable Player Bumgarner, who was working on a perfect game two outs into the eight until Padres pinch-hitter Melvin Upton Jr lined a single to centre field on a 2-1 pitch.
Bumgarner then retired the next four Padres in order to finish off his fourth complete game of the season and second shutout.
"I'm not here to throw perfect games or no-hitters," he said.
"They're special, but nothing is going to get in the way of winning the game."
Elsewhere, David Ortiz became the 27th player in MLB history to reach 500 homers as Boston Red Sox beat Tampa Bay Rays 10-4.
Having smashed homer 499 in the first innings, he reached the milestone when he led off the fifth with a shot to right-centre off Matt Moore.
It was the 50th multi-homer game of Ortiz's 19-year career.
Pitcher Rick Porcello (8-12) got the win for Boston, after allowing three runs and five hits in seven innings.