NEW YORK -- Even their biggest ninth-inning comeback in years wasn't enough for the San Francisco Giants to quell the impending sense of doom that's permeated the team this season.
Christian Arroyo's three-run, tie-breaking double capped a four-run rally in the top of the ninth Wednesday afternoon and provided just enough insurance for the Giants, who snapped a pair of lengthy losing streaks with a 6-5 win over the New York Mets at Citi Field.
The victory ended a five-game skid for the Giants (12-23), who have the worst record in baseball. It was also the first time San Francisco won a game in which it trailed after eight innings in exactly two years -- a stretch of 133 games.
"I don't know if we could have (had) a much-needed win like we had today," Giants manager Bruce Bochy said. "To break a streak, the rut. I know it's been a long time since we've come back down in the eighth. That's huge."
The Mets nearly extended the Giants' misery in the bottom of the ninth, when they recorded three hits off closer Derek Law, including a two-run double by Wilmer Flores that came within a couple feet of becoming a three-run homer.
"I thought it was going to go out," said Posey, who drew a walk immediately before Arroyo's hit. "Then he almost made a heckuva play out there. Then I was thinking 'Maybe he knocked it over the wall.' And then I saw the replay and felt better."
The Giants could finally afford to laugh about their pessimism when Law closed out his second save by retiring Kevin Plawecki on a squibber in front of the plate.
"Yeah, I think they're just having fun with me," Bochy said with a grin. "It's unbelievable. Three-run lead. Couple feet, that ball was, from going out. Tying run on second base. I'm not surprised, to be honest."
Arroyo was in Class A ball the last time the Giants won a game in which they trailed after eight innings, on May 10, 2015. Current Houston Astros outfielder Nori Aoki drew a bases-loaded walk before current Tampa Bay Rays infielder Matt Duffy laced an RBI single to lift San Francisco to a 3-2 win over the Miami Marlins in that one.
On Wednesday, Joe Panik drew a one-out walk against Mets closer Jeurys Familia (1-1) before Flores misplayed a potential double-play grounder to third by Eduardo Nunez. Flores recovered to throw to second, but his attempt was high and drew Neil Walker off the bag.
Hunter Pence's single past a diving Flores scored Panik and set the stage for Posey and Arroyo to conclude the rally.
"Really put together some good at-bats all the way through," Posey said. "Arroyo with the big hit there, that's one that he'll always remember."
Arroyo, a 21-year-old who is batting .242 with three homers, nine RBIs and 18 strikeouts in his first 62 big league at-bats, stood at second base and pumped his arm enthusiastically as Posey raced home with the third run.
"I think it was just a lot of frustration, a lot of pent-up aggression," Arroyo said. "It went our way one time."
Bryan Morris (1-0) tossed 1 1/3 scoreless innings to pick up the win.
Posey homered leading off the second and singled and scored on a sacrifice fly by Ruggiano in the sixth. Posey, who homered in all three games, joined Arroyo, Ruggiano, Nunez and Nick Hundley with two hits apiece.
The loss was just the fourth in the last 12 games for the Mets (16-17), who were trying to move over .500 for the first time since Apr. 19.
"The walk to Panik hurt us," Mets manager Terry Collins said. "The error hurt us and they got a big hit. That's the way baseball is."
"We were right there where we want to be," Flores said. "Just a little mistake cost us the game."
Giants right-hander Matt Cain yielded three runs (two earned) on four hits and two walks while striking out three over five innings.
Milone allowed two runs on six hits and two walks while striking out five over five innings in his Mets debut. He was claimed off waivers from the Milwaukee Brewers on Sunday.
NOTES: Mets OF Michael Conforto (hamstring) did not start Wednesday but singled as a pinch-hitter. Conforto batted .343 with six homers and 15 RBIs in his previous 17 games but manager Terry Collins wanted to give him two days to rest a tight hamstring. The Mets are off on Thursday. ... The Giants recalled RHP Reyes Moronta from Double-A Richmond. Moronta takes the roster spot of RHP Mark Melancon (right pronator strain), who was placed on the 10-day disabled list just before first pitch Tuesday.