MIAMI (AP) Brad Hand earned his first victory as a starter since 2011 when he outpitched Tim Lincecum by a margin of one curveball.
Lincecum bounced a curve for a wild pitch that scored a runner from third in the seventh inning, putting the Miami Marlins ahead to stay Sunday as they snapped a six-game losing streak by beating the San Francisco Giants 3-2.
''It's a very tough way to lose a ballgame,'' Giants manager Bruce Bochy said. ''Timmy threw great.''
NL hits leader Casey McGehee homered for the second time this season to help Miami avert a three-game series sweep.
Hand (1-2) gave the Marlins' shaky rotation a welcome boost by pitching seven innings to match a career high, and he allowed two runs. The left-hander had been 1-12 previously as a starter.
''He got a little squirrelly a couple of times but was able to get it back,'' manager Mike Redmond said. ''That's what we're looking for. It's all about consistency. We want this guy to be in our rotation. We feel he has the stuff. It comes down to him going out and doing it.''
Hand allowed six hits and one walk. He has a 3.22 ERA in four starts since rejoining the rotation.
''I was just trying to go out there and get deep into the game,'' he said. ''I'll try to build on this one and go out there in five days and do it again.''
Steve Cishek pitched a perfect ninth for his 21st save in 24 chances.
Lincecum (9-6) allowed three runs in seven innings, ending his streak of wins in four consecutive starts.
With the score 2-all, Adeiny Hechavarria doubled to start Miami's seventh, took third on a sacrifice and came home when Lincecum misfired a curve to Reid Johnson, and the ball caromed away from catcher Hector Sanchez.
''I was just trying to get him to chase and be aggressive in that situation,'' Lincecum said. ''I didn't do that, and the ball squirted away.''
McGehee came in with 118 hits and 54 RBIs, but the two-run homer in the first inning was his first since May 10.
''It's a little weird,'' the Marlins' cleanup hitter said. ''I would have thought maybe I would have run into a couple more. But it doesn't bother me too much, and until the guys give me a hard time about it, I don't really think about it.''
McGehee had two hits to hike his average to .322. He also made a barehanded grab and throw at third base to rob Buster Posey of a hit in the eighth.
The Giants' offense, which has sputtered for much of July, suffered a relapse after three consecutive robust games. Their final 12 batters went down in order.
Posey drove in their runs with a double in the third.
Miami won with only six hits and despite a succession of basepath blunders. The Marlins had three runners tagged out between second and third in the first three innings.
''What irritates me at times is it takes away from a nice win,'' Redmond said. ''We're making mistakes we shouldn't make and just can't happen.''
NOTES: Giants 1B Brandon Belt will go on either the seven-day or 15-day DL because of a concussion, Bochy said. Belt was struck by a ball in the face during batting practice Saturday. ... Marlins RHP Henderson Alvarez may be able to make his next turn as scheduled, depending on how he feels in the next couple of days, the Marlins said. He left Saturday's game with a bruised left shin after being hit by a comebacker. ... Before the game, the Marlins optioned INF Ed Lucas to Triple-A New Orleans and recalled RHP Anthony DeSclafani from New Orleans. ... Giants 2B Marco Scutaro (stiff neck) was back in the starting after missing three games and singled in the third for his first hit this season. ... RHP Ryan Vogelsong (5-7, 3.86) is scheduled to pitch for the Giants when they open a four-game series Monday at Philadelphia against LHP Cliff Lee (4-4, 3.18). ... RHP Tom Koehler (6-7, 3.99) is scheduled to start for the Marlins when they open a four-game series Monday at Atlanta against RHP Julio Teheran (9-6, 2.71).