NEW YORK (AP) -- Michael Cuddyer and the New York Mets got one big hit after another Thursday night. Quite a contrast from the series opener against San Francisco, when they didn't muster any.
Cuddyer singled home the winning run in the bottom of the ninth inning, and the Mets topped the Giants 5-4 to prevent a three-game sweep and move back into first place in the NL East.
''It's huge morale-wise for us,'' manager Terry Collins said. ''Today was a big one.''
Curtis Granderson scored twice and drove in a run to help New York win on a 91-degree night when chants of ''Let's go Giants!'' rang out at Citi Field. The Mets beat the defending World Series champions for only the second time in 11 meetings, rebounding from a pair of humbling losses to start the series.
San Francisco rookie Chris Heston pitched a no-hitter Tuesday, and Mets ace Matt Harvey was hit hard again the following night. So when New York finally pulled this one out, no wonder it was a relief.
''Hard-fought series. Good road trip,'' Giants manager Bruce Bochy said. ''You'd like to get greedy and get this one, but we just couldn't hold the lead.''
Sergio Romo (0-3) hit Granderson in the back on an 0-2 pitch with one out in the ninth. Granderson advanced to second on Andrew Susac's passed ball and third on Juan Lagares' groundout before Lucas Duda was intentionally walked.
Cuddyer, who had a go-ahead double in the fifth, stroked a sharp single into center field and raised his right arm as he headed for first base, just ahead of the swarm of teammates that chased him down to celebrate.
''It's definitely a good feeling,'' Cuddyer said. ''To get swept at home ... leaves a bad taste in your mouth.''
It was Cuddyer's first game-ending hit in nine years.
''I knew it'd been a long time because I don't remember the last one,'' he said with a smile.
Reminded it was a pinch-hit homer for Minnesota against the Angels on April 19, 2006, he said: ''I do remember it then!''
Jeurys Familia (2-0) pitched a scoreless inning for the win.
Mets starter Jonathon Niese went seven innings in his second consecutive encouraging performance. He got 15 outs on the ground after entering 0-4 with a 7.96 ERA in his last five games.
''A good outing to build on. My stuff felt great,'' Niese said. ''My mechanics are more sound.''
The left-hander retired 12 in a row before substitute third baseman Eric Campbell committed a two-out error in the sixth. Brandon Crawford followed with his ninth homer, a long drive into the Giants' bullpen in right-center that gave San Francisco a 4-3 lead.
Hunter Strickland gave up three straight Mets hits to the start the seventh, including a leadoff double by pinch-hitter Darrell Ceciliani and Granderson's tying single.
Tim Lincecum held the Mets hitless until Travis d'Arnaud blooped an RBI double with two outs in the fourth. Niese opened the fifth with a double to deep center and scored on Duda's sacrifice fly. Cuddyer put the Mets up 3-2 with a two-out RBI double.
''I felt good all night,'' Cuddyer said.
Looking to win his seventh straight decision against New York, Lincecum was lifted after 4 2-3 innings.
The first four batters reached safely against Niese, and San Francisco scored on Buster Posey's run-scoring single and Justin Maxwell's double-play grounder.