SAN DIEGO -- Matt Harvey kept New York ahead early on and Antonio Bastardo came through with a nifty eighth-inning rescue, allowing the Mets to take sole possession of first place in the NL East for the first time this season.
With Washington losing 4-3 in 13 innings at Chicago, the Mets moved into first place. They trailed the Nationals by five games in mid-April.
The Mets won the final two games of the series after being held to three runs and seven hits in losing the first two.
San Diego loaded the bases with no outs in the eighth but failed to score. Jon Jay singled off Jerry Blevins before former San Diego State pitcher Addison Reed came on and allowed singles to Wil Myers and Matt Kemp. Jay might have been able to score on Kemp's single, but third base coach Glenn Hoffman held him.
Bastardo "kept the ball away and up, tough balls to get on top of," Mets manager Terry Collins said. "And he's got real good numbers against a couple of those guys he faced, and he showed it again today."
Upton banged his helmet against a wall twice when he returned to the dugout.
Harvey (3-4) allowed two runs and four hits. It was the 11th time he reached double-digit strikeouts.
Harvey also had two hits, including a double off the center-field wall in the sixth, and scored a run. Asdrubal Cabrera had two RBI singles.
"I finally felt the majority of the game a lot more comfortable and was able to pound the zone, able to throw all my pitches," Harvey said. "Unfortunately there in the fifth left one over the middle but other than that it was a successful day."
Harvey was cruising with a 3-0 lead before Christian Bethancourt connected for a two-run homer into the second deck in left field with one out in the fifth, his second.
"He really had to grind, and in the fifth inning he could have broken down but he didn't, he stayed and kept throwing the ball well," Collins said. "It was a good outing for Matt. I think he should really take advantage of this one and move on."
Cespedes homered for the third time in the series, lining a solo shot off Andrew Cashner (2-3) into the left-field seats leading off the third. It was his 11th on the year.
Cespedes has six homers and 16 RBI in his last 11 games.
Cashner was thrown out trying to score from first on Jay's double to right to end the fifth. The Padres challenged but the call was confirmed.
Cashner came out with cramping in his right hamstring after working a 2-2 count against Campbell leading off the sixth.
Padres manager Andy Green said Cashner is OK.
"How many times do pitchers go from first to home as hard as they absolutely can?" Green said. "He expended himself through five innings. After that run both of his hamstrings were locking up on him."
Green said Hoffman made the right decisions to send Cashner in the fifth and hold Jay in the eighth.
"We had three chances to drive in the guys with the bases loaded and nobody out. That's on us as a team collectively to pick that run up, to pick multiple runs up," Green said. "You want to be a little bit more risk-adverse at third base with nobody out. You want to be more assertive with two outs. I think that's what Hoffy's doing over there. We had three chances to bring them home."
Harvey doubled with one out in the sixth, advanced on Curtis Granderson's groundout and scored on Cabrera's single to make it 4-2.
San Diego pulled to 4-3 in the seventh when Bethancourt doubled, advanced on a fly ball and scored on a balk by Jim Henderson, who appeared to slip.
Padres: 2B Jemile Weeks was placed on the 15-day disabled list after he strained his right hamstring trying to beat out a bunt Saturday night. The Padres recalled INF-OF Jose Pirela from Triple-A El Paso.
Mets: LHP Steven Matz (4-1, 2.83 ERA) is scheduled to start the opener of a four-game series at the Los Angeles Dodgers on Monday night. The Dodgers will counter with LHIP Scott Kazmir (2-2, 5.68 ERA).
Albert Pujols reiterates he'll decide future after season with Los Angeles Angels
Following last week's misinterpreted Instagram post, Albert Pujols reiterated his stance that he hasn't decided whether to retire after this season
Revisiting Miguel Cabrera's 2020 homers
As Miguel Cabrera attempts to get to 500 career home runs, relive all the dingers he hit during the 2020 season.
Detroit Tigers slugger Miguel Cabrera hopes to reach 500 home runs, 3,000 hits in 2021 season
Tigers star Miguel Cabrera is 13 home runs shy of 500 for his career and 134 hits short of 3,000. He hopes to reach both milestones this season. "We can do both," he said.
Chicago Cubs' Joc Pederson, Javy Baez both have something to prove, but for different reasons
Chicago Cubs shortstop Javy Baez and left fielder Joc Pederson both have something to prove in 2021, but for different reasons.
Los Angeles Angels re-sign veteran right-hander Jesse Chavez to minor league deal
Veteran right-hander Jesse Chavez is re-signing with the Los Angeles Angels on a minor league deal.
Marla Miller retiring as MLB's head of special events after 21-year run
Marla Miller, MLB's first female senior vice president, is stepping down after 21 years of being in charge of planning the league's special events, including the All-Star Game and World Series.