NEW YORK (AP) -- Ryan Vogelsong's strategy in the dugout before the ninth inning was simple: keep quiet.
Tired but eager for a shot at his first nine-inning complete game, the right-hander chose not to answer his coaches when asked how he was feeling.
He was just fine, finishing off his second career complete game with a perfect ninth to lead the San Francisco Giants to a swift 5-1 victory over the New York Mets on Friday night for their second straight win after a six-game skid.
"I just kind of didn't answer them because I didn't want to come out," said Vogelsong, who had a six-inning complete game against the Cubs in 2011. "It was something I wanted to do."
Vogelsong (6-8) faced 28 batters, one over the limit, allowing Juan Lagares' soft single leading off the sixth and Lucas' Duda's 20th homer to start the eighth. In ending a five-decision losing skid, he walked one and got two double plays. Vogelsong threw 102 pitches in the game that took 2 hours, 6 minutes.
Brandon Crawford had a run-scoring single, Matt Duffy an RBI single for his first big league hit and Hunter Pence added a two-run triple and RBI groundout off Jonathon Niese (5-7) for San Francisco.
The Giants were coming off a horrid homestand in which they lost five of six to fall out of first place in the NL West. They improved to 30-20 on the road.
"We normally play very well at home," Giants manager Bruce Bochy said. "We just have a tough time scoring runs there. I don't know what to do to change it but we're working on it."
After giving Vogelsong no run support in five of his last six outings, the Giants got on the board in the second thanks in part to Niese's throwing error.
Juan Perez led off with a double. Gregor Blanco then bounced back to Niese. The left-hander tried to nab Perez, who got caught off second, but he bounced the throw and Perez raced into third. Crawford followed with an RBI single and Pence drove in another with a grounder.
"It's unfortunate, because that's a situation where I can't make a mistake, and I did," Niese said. "Just made a mistake and paid for it, costing us runs and, ultimately, the game."
Pence tripled to right-center after Crawford tripled down the right field line and Vogelsong was hit by a pitch in the seventh. Pence was 4 for 33 coming in.
Niese pitched 8-plus innings and allowed nine hits and five runs -- three earned. He hit two batters.
Giants: Right-hander Matt Cain needs surgery to remove bone chips from his elbow. He still is not sure when he will have the operation but Bochy thinks the former ace is done for the season. Recovery is about three months.
Mets: Ace Matt Harvey threw off the mound for first time since having Tommy John surgery on Oct. 22. He made 15 pitches at about 60 percent effort. Harvey still is hoping for a possible return in late September. "I'm not writing 2014 out, but there's still a lot more to go and a lot more to prove in order to be healthy enough to come back," Harvey said.
Giants: Right-hander Jake Peavy (0-1) will make his second start for San Francisco. Peavy has lost his last 10 decisions -- nine with Boston -- but has had success at Citi Field. He is 2-0 with a 3.09 ERA against the Mets in Queens.
Mets: Right-hander Jacob deGrom (5-5) has won four straight starts. According to research by the Elias Sports Bureau, he is one of four rookie pitchers since 1982 to win four consecutive starts of six innings or more while allowing no more than one run. The others are Roy Oswalt, Jered Weaver and Cain.
The Giants promoted Duffy and outfielder Jarrett Parker from Double-A Richmond to take the roster spots of Dan Uggla and Tyler Colvin, who were designated for assignment. Duffy started at second base and singled in a run in the seventh for his first career hit. He rounded first with a big grin as Pablo Sandoval, near the on-deck circle called for the ball. "I didn't have as many nerves as I thought I would," Duffy said.
The Giants have scored 12 runs in their two wins after scoring six total in the six straight losses.
12 FIRST BASEMEN WITH 20
Duda became the 12th Mets first baseman to reach 20 homers in a season. Ike Davis, whom New York traded to Pittsburgh after giving Duda the starting role, was the most recent in 2012.