NEW YORK (AP)Pete Alonso lifted the ball into the left-field seats and sent the New York Mets soaring into their high-profile Subway Series matchup against the Yankees and Aaron Judge.

Alonso hit a go-ahead, three-run homer off Joe Musgrove and had four RBIs to retake the major league lead, leading the Mets over the San Diego Padres 8-5 on Sunday night and avoiding a three-game sweep.

Next up: a two-game series against the Yankees at Citi Field starting Tuesday night. Both teams lead their divisions, and Alonso’s 82 RBIs are one more than Judge’s total.

”I wouldn’t really call it toe to toe, me versus him,” Alonso said. ”This is a moment where the city can come together over the game of baseball.”

San Diego had won the first two games of the weekend series behind Yu Darvish and Blake Snell. The Padres took a 1-0 lead in the sixth behind Joe Musgrove and had not trailed in 25 innings.

New York’s NL East lead was down to a half-game over defending World Series champion Atlanta.

”We just ran into two buzz saws,” Alonso said. ”We needed this one. This one was huge for us today.”

Eric Hosmer provided Musgrove (8-3) a 1-0 lead with a run-scoring double in the sixth off Drew Smith (2-3), but the Mets rallied in the bottom half on the sweltering night and reopened a 1 1/2-game lead over the second-place Braves. New York avoided a three-game sweep and what would have been its first four-game losing streak this year.

Alonso hit his 25th home run in a five-run sixth and added an RBI double high off the center-field wall in a three-run seventh that built an 8-1 lead.

After wasting a second-and-third, no-outs threat in the fifth, the Mets pressured again when Starling Marte singled leading off the sixth and Francisco Lindor doubled.

Pitching coach Ruben Niebla went to the mound, and Musgrove hung a 2-1 slider that Alonso hit into the left-field seats.

”You can’t hit a five-run homer and you can’t hit a four-run single,” Mets manager Buck Showalter said. ”Sometimes you want something too much, and something like that might let you kind of get back into the flow of who you are.”

Daniel Vogelbach, making his Mets debut, got New York’s first hit in the fifth, then walked and scored in the sixth when Luis Guillorme hit a perfectly placed two-out RBI single on a jam shot off Nick Martinez that dropped into shallow left as shortstop Ha-Seong Kim pulled up. Tomas Nido followed with an opposite-field RBI double that hopped off the right-center fence.

Rookie center fielder Esteury Ruiz allowed Alonso’s double against Steven Wilson to go over his glove and high off the wall, Mark Canha followed with an RBI infield hit on a slow roller and third baseman Manny Machado threw past first for a run-scoring error.

Vogelbach, acquired Friday from Pittsburgh, went 1 for 3 and received a warm ovation. He had been 0 for 8 against Musgrove.

”I don’t know that I’ve played in an environment like that – at least being the home team.” Vogelbach said. ”Pretty cool to call it my home field now.”

STARTERS

Mets starter Carlos Carrasco allowed six hits over five scoreless innings on the 90-degree night. Musgrove, 0-3 in his last five starts, gave up four runs and five hits in 5 1/3 innings.

CLOSER

Machado had three hits, included an RBI double in a three-run ninth off Joely Rodriguez. Edwin Diaz, energizing the crowd when he entered to Blasterjaxx & Timmy Trumpet’s ”Narco,” relieved with two on and got three outs for his 21st save in 24 chances.

WEB GEM

New York’s Brandon Nimmo made a leaping catch against the center-field wall in the sixth to rob Austin Nola of a run-scoring extra-base hit.

PLUNKED BUT NO BASE

Machado struck out leading off the sixth when he was hit on a hand by a Smith changeup, but first base umpire Angel Hernandez ruled Machado swung at the 0-2 pitch.

TRAINER’S ROOM

Padres: CF Trent Grisham didn’t play, a day after leaving in the eighth following a collision with pitcher Chris Bassitt. … INF C.J. Abrams (sore biceps) was out of the lineup for the second straight day. … OF Wil Myers (right knee inflammation) will need additional minor league rehab games in the coming week. … LHP Drew Pomeranz threw about 20 pitches Saturday in his first simulated game following flexor tendon surgery last August.

Mets: RHP Jacob deGrom (stress reaction in his right scapula) threw a side session at Citi Field and will make at least a fourth minor league rehab start. The 34-year-old right-hander, a two-time NL Cy Young Award winner, has not pitched in the major leagues since July 7 last year. … RHP Trevor May (right triceps inflammation) threw 14 pitches during a one-inning appearance for Double-A Binghamton.

Booth: ESPN and YES broadcaster David Cone worked his first game since the former big league pitcher had hip replacement surgery on July 11.

UP NEXT

Padres: LHP Sean Manaea (5-4, 4.11) is to start Monday night at Detroit against RHP Drew Hutchison (1-4, 4.46).

Mets: RHP Taijuan Walker (7-2, 2.55) is 4-0 with a 1.80 ERA in his last seven starts going into his Tuesday outing against LHP Jordan Montgomery (3-2, 3.24).

More AP MLB: https://apnews.com/hub/MLB and https://twitter.com/AP-Sports