SAN FRANCISCO (AP) — Jeff Samardzija lost his bid for a no-hitter, then Yoenis Cespedes punished a mistimed curveball. That was enough to drop the San Francisco Giants out of first place.

Noah Syndergaard and Jeurys Familia combined on a three-hitter and Cespedes homered off Samardzija, leading the New York Mets over San Francisco 2-0 on Sunday night.

Samardzija (10-9) held the Mets hitless until Curtis Granderson's leadoff double in the seventh. Cespedes followed with his 25th home run, a towering two-run blast that appeared to clear the stands in left field.

"You don't really worry about that (the no-hitter) until later in the game," Samardzija said. "For me, I was just worried about the score."

The Giants dropped to second in the NL West after entering the day with a half-game lead on the Dodgers. Los Angeles beat Cincinnati earlier Sunday.

Samardzija was sharp for a third straight start that followed a stretch of 11 outings in which he had just two quality starts.

"I liked where he's at and he carried that into today's game," Giants manager Bruce Bochy said. "He pitched his heart out and ran into a hot hitter."

Samardzija tried to sneak a 1-0 curveball past Cespedes, who homered for the third time in two days to help split the four-game series.

"We were behind in the count and I assumed (Cespedes) was sitting heater and I thought we could get something he could roll over there or a swing and miss," Samardzija said. "He's a heck of a hitter, I played with him in Oakland and I know what he can do. He's a clutch guy."

Syndergaard (11-7) allowed two hits over eight innings for his second consecutive win following a six-start skid. It's Syndergaard's 20th career victory in 49 games.

"That's just a great pitching effort by (Samardzija), he did a terrific job, he gave us a chance against one of the best," Bochy said. "You're not going to see better stuff than what we faced tonight.

"I don't know who would have hit (Syndergaard) tonight. He was that good."

Familia retired three batters for his major league-leading 41st save. It was also the 900th victory of manager Terry Collins' career, making him the 10th active manager to reach the milestone.

"We've had a tough time, but if you're going to win, your good players have to play good," Collins said. "We ride those guys. Hopefully this is the start of what we've been looking to do."

Samardzija remained winless in four career starts against the Mets. Samardzija allowed only three hits and two runs over seven innings and struck out seven.

The duel between Syndergaard and Samardzija was in stark contrast to the first three games of this series, when the teams combined for 40 runs. Only two runners from either team reached second base Sunday, and both scored.

San Francisco's first two baserunners were thrown out trying to steal second. Catcher Rene Rivera caught Trevor Brown in the third and Eduardo Nunez in the fourth. Prior to that, opponents had successfully stolen 40 bases in 44 attempts against New York with Syndergaard on the mound.

The Giants also made a pair of sparkling defensive plays. Brandon Crawford made a diving stop on Jose Reyes' sharp liner in the first inning, then second baseman Joe Panik robbed Reyes of an infield single with two outs in the sixth when he fielded a slow grounder and flipped it to first base with his glove.

STOP, DROP AND ROLL

Mets third base coach Tim Teufel had to react quickly to avoid being hit by a line drive from left-handed hitting James Loney in the fifth. The ball narrowly missed Teufel as he dropped to the grass on his back.

TRAINER'S ROOM

Giants: Buster Posey did not start but had a pinch-hit single in the ninth. ... OF Angel Pagan was kept out of the lineup with tightness in his groin. Pagan has the longest active hitting streak in the majors at 18 games.

UP NEXT

Giants: Madison Bumgarner (12-7) faces the Dodgers on Tuesday to begin a key series in Los Angeles between the top two teams in the NL West. Bumgarner is winless in two previous starts against the Dodgers this season.