Tom Koehler (4-3) struck out seven in seven innings to finally win in five tries away from South Florida after coming into his outing 0-3 on the road to start the year. He allowed four hits and walked two in his first road victory since Sept. 22 at Washington.
Garrett Jones hit an RBI triple, Jarrod Saltalamacchia had a sacrifice fly and Adeiny Hechavarria singled in a run for Miami. The Marlins improved to 11-2 at AT&T Park since 2011.
Tim Lincecum (3-3), coming off his best start of the year with an 11-strikeout performance in a season-high 7 2-3 innings to beat Atlanta on Monday, never found his groove.
On a night thousands in the sellout crowd donned orange giveaway Fedoras, the Giants were handed back-to-back home losses for just the second time all year and first since April 9-10 against Arizona.
San Francisco figures it missed a scoring opportunity in the second via a replay review.
Marlins manager Mike Redmond requested a review of whether Brandon Hicks touched first base on a second-inning double. The play was overturned in 2 minutes, 42 seconds, and became a putout from the pitcher to first baseman. That left Hector Sanchez on third with two outs, and Brandon Crawford ended the inning on a deep fly to center.
Stanton, whose career-high 17-game hitting streak ended with an 0 for 5 on Friday, hit a two-out triple in the third — his first since Sept. 15, 2012, off Cincinnati's Johnny Cueto. Stanton hit his 12th homer in the seventh.
Kevin Slowey, Miami's third pitcher, got into trouble in the ninth and Steve Cishek entered to finish the six-hit shutout with his ninth save. San Francisco went 0-6 with runners in scoring position and left nine on base.
Suspended infielder Miguel Tejada was quoted as telling ESPN Deportes he had signed a minor league contract with the Marlins pending a physical. He served 41 games of a 105-game suspension last year for testing positive for an amphetamine. Tejada would be eligible to play in the Marlins' 65th game, which barring rainouts would be June 10 at Texas. He could appear in minor league games at Double-A or lower on May 31.
NOTES: Giants C Buster Posey had the night off until grounding out as a pinch-hitter in the ninth. ... Giants RHP Tim Hudson tested his strained left hip with an up-tempo throwing session on flat ground and was scheduled to throw a bullpen Sunday. He's on target to make his next start Thursday at Colorado. "I should be good by Thursday," Hudson said. "It's feeling a little better every day." He made 30-40 throws from up to about 80 feet. ... Both managers were still talking about a pair of exclamation-point catches a night earlier — Stanton's grab of a fly by Michael Morse at the StubHub! sign in right field and San Francisco CF Angel Pagan's over-the-shoulder catch of a ball by Derek Dietrich at the YAHOO! sign in left-center.