Buehrle (5-4) worked around eight hits to win his third straight start. The veteran left-hander didn't issue a walk and struck out three.
Logan Morrison's second RBI of the game -- a double to score Giancarlo Stanton in the sixth -- gave the Marlins a 5-1 lead.
The Giants narrowed the gap with runs in the eighth and ninth, but Randy Choate recorded the final two outs of the game to record his first save.
San Francisco starter Madison Bumgarner (5-4) lost for the third time in four outings, yielding five runs (four earned) on seven hits over six frames while walking two and fanning seven.
Gregor Blanco went 3-for-5 with an RBI for the Giants, who dropped their second straight in the four-game series.