Tim Lincecum allowed just three runs over six innings, but Koehler threw seven shutout innings, and the Giants took a 5-0 loss at AT&T Park.
"It was a quality start, three runs, six innings," Giants manager Bruce Bochy said. "That's not bad. The way we're swinging the bat, you take your chances with that, but we just got shut down offensively."
The Marlins took a 1-0 lead in the top of second. With two outs, Lincecum issued back-to-back walks to catcher Jarrod Saltalamacchia and center fielder Marcell Ozuna. Shortstop Adeiny Hechavarria grounded a single to right, and Saltalamacchia beat right fielder Hunter Pence's throw home, avoiding catcher Hector Sanchez's diving tag attempt.
The Giants squandered a great chance to answer back in bottom of the inning. Sanchez walked and moved to third on an apparent double by Hicks. Miami made an appeal at first, claiming Hicks missed the base, but he was ruled safe. Marlins manager Mike Redmond challenged the ruling, and after a video review, it was overturned. Hicks was out, and shortstop Brandon Crawford was retired on a fly ball to deep center field, ending the inning.
"The play to Hicks, that was costly," Bochy said. "I've looked at it. It's hard to tell. They may have a different angle, but I couldn't tell to where they could overturn that, but it's obvious they saw it. It's such a huge play. There's one out, runners on second and third, chances are you're going to get at least one run in."
Hicks nearly hit the ball out of the park but settled for an embarrassing out.
"I thought I touched it," Hicks said. "I felt like I did a little bit, but I looked up at the same time. I was trying to find where the ball was at."
Lincecum (3-3) recorded his second straight quality start and fourth of the season. He struck out six, walked three and threw 114 pitches, 70 for strikes. He gave up a run in the second and two in the sixth.
"I don't think I had a clean inning except for the first," Lincecum said. "Just take away the positives. There were some. That sixth inning kind of bit us."
Koehler (4-3) allowed just four hits while striking out seven and walking two. He had his first career Major League win June 20 last season at AT&T Park, allowing one run and three hits over seven innings. This time he captured his first road victory of the season after three losses.
"Just came down to command," Marlins manager Mike Redmond said. "He was down in the strike zone and he had a great feel for his breaking ball. Threw some great breaking balls, threw some great sliders at times when he needed to. The key for Tommy is to pound the strike zone. When he keeps the ball down, he's pretty tough."
The Giants had just one extra-base hit off Koehler, a triple by Pence with two outs in the third, but third baseman Pablo Sandoval struck out. In the ninth, Michael Morse singled, Sanchez doubled and Crawford walked to load the bases off Kevin Slowey before Marlins closer Steve Cishek struck out Tyler Colvin to end the game.
Miami added two runs in the sixth off Lincecum. Third baseman Casey McGehee lined a leadoff double to left-center field. McGehee scored on first baseman Garrett Jones' triple to left-center that got past a diving Angel Pagan. Pagan landed hard on his left elbow and shoulder but stayed in the game. Saltalamacchia brought Jones home with a sacrifice fly to deep left field.
Pagan said the team doctor examined him after the game and found nothing broken and no major injury.
"It's sore right now," Pagan said. "The question is how it will feel tomorrow. I'm sure tomorrow it will be a little more sore. It's pretty banged up."
Marlins right fielder Giancarlo Stanton made it 4-0 in the seventh with his 12th home run of the season, a solo shot off left-hander David Huff over the right-center wall. Huff gave up an unearned run in the ninth on pinch-hitter Jeff Baker's RBI single following Pence's error that put Hechavarria on second.