The Mets got a walk-off ninth-inning home run from Francisco Alvarez to survive giving away a 3-0 lead to beat the Baltimore Orioles 4-3 on Monday night at Citi Field.

It was the first career walk-off hit for the Mets’ catcher and his first home run since July 26 when he took Baltimore’s Seranthony Dominguez deep into the gap in left-center 421 feet to end the game.

New York improved to 65-60 to keep pace in the NL wild card race.

Here are the takeaways…

– David Peterson has been stung by the walk and lost the game’s leadoff hitter Austin Slater after getting ahead 0-2. But the lefty got past Baltimore’s dangerous duo with Adley Rutschman tapping into a tailor-made 6-4-3 double play and Gunnar Henderson swinging through a 3-2 pitch.

Pitching with a lead, Peterson needed just nine pitches in the second and, despite allowing a leadoff single in the third, kept the O’s off the board adding two more swinging strikeouts in the process.

A pair of two-out singles set up Eloy Jimenez with an RBI chance, but a grounder to third was smothered by a diving Mark Vientos at third to get Peterson out of the jam.

The fifth inning has been a bugaboo for Peterson and a one-out double to the corner in left off Ramon Urias’ bat and a failed pickoff attempt put the runner on third. And that allowed Baltimore to get on the board on a Jackson Holliday groundout to first.

Three groundouts – giving him nine on the night – got the lefty through six frames on just 87 pitches. Peterson had allowed just four balls in the air, two of which were flyouts.

Ryan Mountcaslte belted his second hit of the night for a leadoff double to start the seventh. After getting a groundout and a strikeout, Peterson was close to getting out of it, but he balked in Mountcastle from third and on the very next pitch hung a sinker over the plate to Urias and he clocked it 107.3 mph and 432 feet to left center for a game-tying home run.

The left-hander’s longest start of the season ended on a sour note, his final line: 7.0 innings, six hits, three runs (two earned), one walk and eight strikeouts on 101 pitches (68 strikes).

– In the first inning, Vientos, batting in the two-hole, took a 3-2 pitch and poked it the other way off Orioles starter Trevor Rogers for a single and that set up J.D. Martinez to drive the first pitch he saw into the bullpen for an opposite-field two-run homer. Rogers missed his spot as the 92 mph sinker leaked into the inner half of the plate and the DH lined it 393 feet, 100.1 mph off the bat for his first dinger in 50 plate appearances.

– Pete Alonso started the fourth by driving an 0-2 changeup to the gap in left-center for a double and came around to score on a two-out single from Tyrone Taylor to make it 3-0.

– Starling Marte drove a single to center with two outs in the first inning and promptly stole second base. He got a big chance in the fifth with two on and two outs but went down swinging against Baltimore reliever Colin Selby.

After allowing three runs early, Baltimore’s pitchers started to get the better of the Mets batters, who managed just one fair ball over the next four frames while striking out nine times. In fact, the Taylor single was the Mets’ last hit before Alvarez’s homer.

Overall, New York left five runners on base and went 1-for-6 with runners in scoring position.

– Jose Butto got the eighth inning and had trouble with the strike zone, but got the first two before walking Henderson to bring up the dangerous Anthony Santander, but a first pitch pop-out ended the inning.

– Edwin Diaz, in a non-save situation, struck out Mountcastle swinging, pinch-hitter Ryan O’Hearn to ground out, and Colton Cowser to pop out.  It was just his fifth appearance this month.

Game MVP: Alvarez

The youngster has been in a bit of a rut at the plate, but the Mets are hoping that his game-winning blast will be able to get him back on track down the stretch.

Highlights

MVP of the Game: Francisco Alvarez

Swinging on a 3-0 pitch he had the hit that ended the night and working behind the plate he got more than a half dozen strike calls from home plate umpire John Tumpane on pitches that were below the zone, much to the chagrin of the Baltimore dugout.

What’s next

The Mets and Orioles continue the series on Tuesday night at Citi Field with a 7:10 p.m. first pitch.

Left-hander Jose Quintana (4.26 ERA and 1.295 WHIP in 129 innings) is looking to bounce back after a few rough outings (nine runs on 11 hits and six walks over his last 10.2 innings.)

Baltimore will hand the ball to right-hander Dean Kremer (4.48 ERA and 1.284 WHIP in 90.1 innings).