Sanchez (8-7) gave up a one-out double to Neil Walker in the second inning and also walked three, but rarely found trouble for only his second win in 16 starts since mid-June.
He retired the final 16 batters he faced after walking Ryan Ludwick with one out in the fourth. Ludwick was retired on a double play, meaning Sanchez faced the minimum in each of his last six innings.
"If he could stay like he pitched tonight he could be an 18-game winner," said Marlins manager Jack McKeon. "But he gets carried away once in a while with that hanging breaking ball ... and stuff like that."
John Buck hit a two-run double and Donnie Murphy had a sacrifice fly during a three-run third inning for the Marlins, who have won both games of this three- game series so far and five of their last seven.
Pirates left-hander Jeff Locke (0-1) took the loss in his major league debut after giving up three runs on five hits and four walks in five innings. He struck out one.
The Pirates have lost nine of their last 13.
They never solved Sanchez, who threw 86 of his 119 pitches for strikes and worked out of a couple of early-inning jams.
"He threw a lot of strikes. He was 0-1 to too many guys tonight and his off- speed stuff was very, very sharp," said Walker. "He's not in the top five in the league in strikeouts, or whatever, for no reason and tonight we found out why."
Walker doubled to left field in the second inning and Ryan Ludwick reached on Matt Dominguez's error at third. After Sanchez fanned Pedro Alvarez, Michael McKenry walked to load the bases.
But Sanchez struck out Jeff Locke on a 2-2 sinker to escape, and the Florida offense gave him a lead in the third when Buck singled to right with the bases loaded. Murphy's sac fly scored a run to make it 3-0, but Buck was doubled off at second base.
Sanchez walked Andrew McCutchen with two outs in the third, then fanned Derrek Lee to end the inning. Ludwick walked after a nine-pitch at-bat in the fourth, but Alvarez lined to Murphy at short, and he doubled the runner off at first.
Sanchez struck out at least one batter in four of the next five innings to collect his third complete game of the season and second shutout. The 27-year- old righty has six complete games and four shutouts in his career.
"I threw a lot of balls in," said Sanchez. "I didn't try to do too much."
Sanchez entered the game 1-6 in his last 15 starts, with the lone win coming on August 16...Locke, 23, was acquired from Atlanta in a June 2009 trade...The Marlins are 2-0 on an 11-game road trip.