SAN DIEGO —Matt Harvey looked like himself again, Antonio Bastardo wiggled out of a late jam, and the Mets took a 4-3 win over the Padres on Sunday, vaulting themselves into first place for the first time this season.

“It’s only May,” manager Terry Collins said, shortly after the Mets nudged a half-game ahead of the Nationals in the NL East. “We’ve got a long way to go.”

The finish line is nowhere close, but the Mets have looked the part of preseason favorites hoping to make good on heavy expectations.

The Mets got a pair of run-scoring singles from Asdrubal Cabrera, and another from Eric Campbell. Yoenis Cespedes belted his 11th home run, his third of the series.

“I’m being a little more selective at home plate,” Cespedes said through a translator. “And it’s allowed me to hit more home runs.”

Meanwhile, Harvey pitched like an ace, breaking from what had been a cycle of frustration. He held the Padres to two runs in six innings and finished with a season-high 10 strikeouts. It was the 11th double-digit strikeout game of Harvey’s career, though only his first in six starts this season.

“I finally felt, the majority of the game, a lot more comfortable,” said Harvey, whose command was noticeably sharper. “I was able to pound the zone, able to throw all my pitches.”

Harvey entered just 2-4 with a 4.76 ERA, pedestrian numbers that he chalked up to an ongoing battle with his own pitching mechanics. That inconsistency led to spotty command, despite velocity that has been on the upswing.

But aside from a two-run shot to Christian Bethancourt in the fifth, a shot that brought the Padres to within one run, Harvey hit his spots.

“It’s the best command I’ve seen him have this year,” Collins said.

Harvey was also helped by what appeared to be a break for the Mets in the fifth, when the Padres lost out on the potential tying run when Andrew Cashner was thrown out at the plate trying to score on Jon Jay’s double.

On replays, Cashner appeared to sneak his hand past Kevin Plawecki to touch home plate. But despite a Padres challenge, umpires upheld the call and Harvey departed with the lead.

In the ninth, Jeurys Familia worked a perfect ninth and improved to 10-for-10 in save chances. But bridging the gap proved treacherous for the Mets, who burned through three relievers before needing some magic.

Jim Henderson balked home a run in the seventh. In the eighth, with a one-run lead to protect, lefty specialist Jerry Blevins allowed a leadoff single to Jay. Setup man Addison Reed followed by giving up a broken-bat infield single to Wil Myers and a soft single to left by Matt Kemp.

Suddenly, the Padres had loaded the bases with no one out, prompting Collins to summon the lefty Bastardo. He whiffed pinch hitter Derek Norris and got Melvin Upton Jr. to pop up, leaving just Alexei Ramirez standing between the Mets and a much-needed reprieve.

Bastardo quickly got ahead 0-and-2 before Ramirez fouled two pitches into the screen and another into the stands. Plawecki signaled for an elevated fastball. Ramirez could only tip the 90-mph offering into the glove of Plawecki, who pumped his fist as the Mets jogged off the field.

“I’m just trying to throw every pitch with intensity,” said Bastardo, who threw nothing but fastballs.

For the first time this season, the Mets (19-11) find themselves where they ended last regular season, in the driver’s seat of the NL East. The Nationals relinquished their lead earlier in the day, when they took the final loss in a four-game sweep to the surging Cubs.