PHOENIX — Francisco Alvarez carried his bat almost to first base, flinging it in the air as the ball disappeared behind the right-field fence.

With two outs in the ninth inning Wednesday night, the game was just getting started for the Mets, who rallied for a 2-1 victory over the Diamondbacks at Chase Field, extending their winning streak to four games.

Alvarez’s tying home run and Mark Canha’s subsequent RBI triple resurrected a team that, beyond its starting pitcher, barely had a pulse all night.

Kodai Senga fired eight dominant innings and matched a career-high with 12 strikeouts but was in position for the loss as Alvarez faced a full-count pitch from lefty Andrew Chafin with two outs in the ninth.

Alvarez hit a fly to right that kept going for his 15th homer of the season and second in as many games.

Brett Baty followed with a single before Canha gave the Mets the lead with a shot that bounced near the 410-foot sign in center field and rebounded for a go-ahead RBI triple.

New York Mets’ Francisco Alvarez (4) celebrates his game-tying home run next to Arizona Diamondbacks first baseman Christian Walker (53) during the ninth inning.

David Robertson pitched a scoreless ninth for his 13th save and second in as many games, following Senga’s longest outing as a major leaguer.

A day after throwing nine pitches to get the final out in the Mets’ 8-5 victory, Robertson fired a perfect ninth that included a Corbin Carroll grounder that caromed off the pitcher to Pete Alonso at first base for the second out.

With the victory, the Mets (40-46) won a second straight series after going more than a month without a series victory.

Senga took a shutout into the seventh, when Christian Walker crushed the right-hander’s second pitch of the inning into the left-field seats for the Diamondbacks’ only run.

Kodai Senga, who allowed just one run in eight innings, picked up his seventh win of the season.
Kodai Senga, who allowed just one run in eight innings, picked up his seventh win of the season.
USA TODAY Sports via Reuters Con

Walker jumped on a hanging slider for the home run, the 10th allowed by Senga this season.

The Mets wasted early opportunities.

In the second inning, Starling Marte was thrown out attempting to reach second on Jeff McNeil’s fly out to center, completing an inning-ending double play.

Canha drew a two-out walk in the third inning and was left stranded before the Mets had their first semblance of a rally in the fourth, getting a leadoff single from Pham before Marte was intentionally walked with two outs.

Pham and Marte executed a double steal, but McNeil grounded out to end the inning.

Mark Canha belts the game-winning RBI triple in the ninth inning of the Mets' comeback victory.
Mark Canha belts the game-winning RBI triple in the ninth inning of the Mets’ comeback victory.
USA TODAY Sports via Reuters Con

Baty and Canha walked in succession in the fifth inning before lefty Tommy Henry fell behind 3-0 to Brandon Nimmo. After Nimmo took a strike, he was retired on a pop up.

Henry escaped by getting Tommy Pham to line to third for the final out.

Senga allowed bloop singles to Geraldo Perdomo and Carroll in the first inning before getting Walker to hit into an inning-ending double play.

Walker walked and stole second with two outs in the fourth, but was left stranded when Lourdes Gurriel Jr. whiffed for Senga’s third strikeout in the inning.

Jake McCarthy singled off McNeil’s glove and stole second in the fifth, but following two strikeouts, Senga retired Alek Thomas on a drive to the right-center gap that Nimmo caught on the run.

Henry allowed two hits and four walks over six shutout innings with two strikeouts.

It marked the second time this season the left-hander has pitched at least six innings without allowing a run.