Pete Alonso scored Francisco Lindor with a go-ahead single in the ninth inning, James McCann homered and drove in four, and the New York Mets beat the Arizona Diamondbacks 7-6 Wednesday.

Lindor reached in the ninth on his third hit, advanced to second on an error by center fielder Ketel Marte and reached third on a passed ball. Alonso then ripped a single through the left side of the infield off Joakim Soria (0-1) for a one-run lead.

Miguel Castro (2-1) got the win with two scoreless innings, and Edwin Díaz recorded his 10th save after blowing his first opportunity of the season Tuesday.

New York Mets' Jonathan Villar slides in head first to score a run against the Arizona Diamondbacks on a ball hit by James McCann in the second inning during a baseball game, Wednesday, June 2, 2021, in Phoenix. (AP PhotoRick Scuteri)

New York Mets' Jonathan Villar slides in head first to score a run against the Arizona Diamondbacks on a ball hit by James McCann in the second inning during a baseball game, Wednesday, June 2, 2021, in Phoenix. (AP PhotoRick Scuteri)

The Mets had 16 hits, one short of tying a season high. New York's second through fifth hitters — Lindor, McCann, Alonso, Kevin Pillar and Dominic Smith — were a combined 13 of 24 with six RBIs.

Lindor had just his second three-hit game of the season. He lifted his batting average to .209, his highest mark since April 27.

Arizona starter Madison Bumgarner lasted just two innings, his shortest outing since Aug. 9, 2020. He allowed five earned runs on eight hits and his ERA climbed to 5.73.

New York Mets pitcher Robert Gsellman makes the play for an out on a ball hit by Arizona Diamondbacks' Ildemaro Vargas in the third inning during a baseball game, Wednesday, June 2, 2021, in Phoenix. (AP PhotoRick Scuteri)

New York Mets pitcher Robert Gsellman makes the play for an out on a ball hit by Arizona Diamondbacks' Ildemaro Vargas in the third inning during a baseball game, Wednesday, June 2, 2021, in Phoenix. (AP PhotoRick Scuteri)

The Mets had six consecutive hits off Bumgarner in the first inning. Jonathan Villar and Lindor led off the game with back-to-back singles and McCann followed with a three-run homer to left field. A double-play groundout by Brandon Drury gave New York a 4-0 lead.

The Diamondbacks responded by batting around and scoring five runs in the bottom of the first inning off Mets starter David Peterson. Marte hit a two-run homer to left field, infielder Ildemaro Vargas — acquired earlier in the day from Pittsburgh for cash — had a two-run single to right and Bumgarner drove in a run with a single.

Peterson lasted just 1/3 of an inning, giving up three hits and five earned runs. He walked three batters.

Arizona Diamondbacks' Ketel Marte celebrates with Carson Kelly (18) after hitting a two-run home run against the New York Mets in the first inning during a baseball game, Wednesday, June 2, 2021, in Phoenix. (AP PhotoRick Scuteri)

Arizona Diamondbacks' Ketel Marte celebrates with Carson Kelly (18) after hitting a two-run home run against the New York Mets in the first inning during a baseball game, Wednesday, June 2, 2021, in Phoenix. (AP PhotoRick Scuteri)

Seth Lugo made his season debut for the Mets and allowed a run over two innings. The right-handed reliever had elbow surgery in February.

BIG WHIFF

Castro tied up Marte so badly with a first-pitch breaking ball in the seventh inning that Marte swung, missed and ended up belly down in the dirt. The right-handed pitcher ran snapped the pitch toward the left-handed Marte's back foot, prompting Marte to swing and jump all in one motion — a move that ended with Marte crashing face-first to the ground.

ROSTER MOVES

Diamondbacks: Arizona acquired Vargas from the Pirates for cash and designated Domingo Leyba for assignment. Vargas hit .077 in 13 games for Pittsburgh. Leyba was 0 for 22 in 13 games. Vargas made Arizona's opening day roster in 2020 but was cut after eight games.

TRAINER'S ROOM

Mets: Villar was removed from the game with right hamstring tightness. ... Manager Luis Rojas said J.D. Davis' minor-league rehabilitation assignment has been postponed because he experienced discomfort in his sprained left hand after taking swings over the weekend. Davis was originally put on the injured list on May 2. He began a rehab assignment May 18 but played in only four games before being shut down.

UP NEXT

Mets: Travel to San Diego for a four-game series. Right-hander Taijuan Walker (4-1, 1.84) will take the mound against Padres right-hander Yu Darvish (5-1, 2.16).

Diamondbacks: Begin a four-game series in Milwaukee. Left-hander Jon Duplantier (0-0, 7.77) will face Brewers left-hander Brett Anderson (2-3, 4.18).

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