Jake Peavy made another good start, and that left San Francisco manager Bruce Bochy feeling encouraged following Giants' eighth loss in nine games.
In his second start after missing 2 1/2 months because of a strained back, Peavy (0-4) gave up two runs in seven innings Wednesday in a 4-1 loss to the New York Mets.
"I felt a little better, more comfortable," Peavy said. "It's just frustrating when you don't do enough to win."
He allowed one earned run and six hits. A day after Matt Cain's first win in nearly a year, Bochy said he felt the rotation was stabilizing.
"I'm very pleased with where they are at," Bochy said. "Really, the whole pitching staff. Right now, we're not clicking offensively. They are going to help us in the second half. There's no question they are going to make us a stronger rotation."
Peavy said the team still feels it has a chance to win the NL West.
"We certainly wanted to get out of this rut," Peavy said. "We had a chance to turn it around today, to go from losing seven in a row to winning the series. ... We can sit around and cry about the first couple months of the season. It hasn't been easy for me or Matt, and we hope we can be a big shot in the arm and be fresh for that stretch run, where you can really be counted on."
All-Star Jacob DeGrom allowed two hits in eight scoreless innings, Eric Campbell hit a two-run homer and the Mets won consecutive road series for the first time this season.
Hunter Pence, in his second game after a stint on the disabled list caused by left wrist tendinitis, had two hits for the Giants and drove in their only run.
New York went ahead when Ruben Tejada singled with one out in the sixth and Daniel Murphy grounded to the shortstop hole. All-Star Brandon Crawford made a diving, backhand stop and, from his knees, threw sidearm to second. The ball rolled into right field as Tejada came around from first.
"I was trying to make a play and stop a rally," Crawford said. "Unfortunately it led to one."
DeGrom (9-6) allowed a double to Pence in the third inning and a bloop single to Brandon Belt in the fourth, then retired 13 consecutive batters. The reigning NL Rookie of the Year, deGrom struck out 10 and walked one. He has a 2.14 ERA and is 5-1 with a 1.09 ERA in day games.
"It's like a video game back there," Mets catcher Kevin Plawecki said. "He's a lot of fun to catch. He got ahead of a lot of guys and was able to throw any pitch he wanted."
Mets starting pitchers, a group that includes Matt Harvey, Noah Syndergaard and Steven Matz along with Bartolo Colon and Jon Niese, have allowed three or fewer hits in each of their last four wins.
"We needed it," deGrom said of the road trip. "It's a good way to go back home."
The Mets had gone 4-18 since winning their last road series, May 8-10 in Philadelphia.
Jeurys Familia got two outs for his 24th save in 26 chances.
Juan Lagaras hit into a RBI forceout in the seventh, and Campbell homered against Jean Machi in the ninth.
Pence had an RBI single in the ninth off Bobby Parnell.
The Mets are a major league-best 20-8 (.714) in day games.
Giants: Buster Posey was out of the lineup a second straight day with a tight hamstring.
Giants: All-Star Madison Bumgarner (8-5, 3.34) starts against Philadelphia and fellow left-hander Cole Hamels (5-6, 3.02) on Friday night.