The Giants have won the World Series two of the past three years.

But the lowly Marlins have been beating them silly at AT&T Park.

Tom Koehler recorded his first major-league victory and Marcell Ozuna’s pinch-hit two-run single in the eighth inning rallied the the Marlins for a 2-1 win, their eighth straight at AT&T Park.

“Outside of the day I met my wife, this is probably the happiest moment of my life right now,” Koehler said. “Definitely my happiest baseball moment.”

Koehler didn’t allow a hit until Gregor Blanco singled with one out in the sixth and took a shutout into the seventh before the Giants edged out to a 1-0 lead on Joaquin Arias’ RBI triple.

But the Marlins, who have struggled for runs on the road trip, came up with a pair in the eighth when Ozuna, who has been slumping, came through with a big two-out single in his very first major league pinch at-bat.

“Today when I come to the park, I said today I’m going to break out of my slump,” Ozuna said.

Ozuna had gone 2 for his last 33 and didn’t start Thursday when the Marlins opened a four-game series against the defending Series champs. But with runners at second and third and two outs, Ozuna was sent in to pinch-hit against Giants pitcher Jeremy Affeldt.

The rookie flared a 0-2 pitch into right for a soft single to put the Marlins ahead 2-1. Ozuna said he couldn’t remember the last time he came through with a pinch hit.

“I think, let me do what I do in [batting practice],” Ozuna said of his thought process when he stepped to the plate in the eighth. “Get the contact! Get the contact! Get the contact! I say, if he throws me in, I’m going to hit a home run. I’m going to swing hard. If he throws me away, I’m going to throw my bat. And that’s what happened. I got a base hit to right field.”

Chad Qualls worked a scoreless eighth, and Steve Cishek pitched the ninth for his 11th save.

It has been a low-scoring road trip so far for the Marlins. Only 14 total runs were scored in their just-completed three-game series against the Diamondbacks, and three of the four games on the trip so far has been decided by one run.