It was a night of mental blunders and drama at loanDeport Park on Tuesday between the Mets and Marlins.

The game started with errors from both teams, leading to four total runs with only two earned. The ending, however, was an odyssey.

Down to their last out and trailing 3-1, the Mets fought back and tied the game. Jeff McNeil and Mark Vientos led off the ninth with a double and single, setting the Mets up for business.

Brad Mills-USA TODAY Sports

After the Mets made two outs and were on the brink of losing, Brandon Nimmo smoked a double off the center field wall, which tied the game at 3-3.

However, the Marlins showed adversity in the middle of their pennant chase and walked off the Mets to win 4-3.

Trevor Gott, who has struggled since being traded to New York, was tasked with holding the game at 3-3. The ninth got off to a rough start when hit Nick Fortes with a pitch to lead off the inning.

Fortes got into scoring position after Xavier Edwards recorded his second sacrifice bunt of the night, and he was in scoring position for Jake Burger after the Mets chose to intentionally walk Jorge Soler.

Burger lined a two-out single into center field, winning the game for the Marlins, who tied the Cubs and Reds for the third National League wildcard after their victory over the Mets.

To make matters worse, the Mets had the chance to end the inning when Burger hit a pop-up toward their dugout, but Francisco Álvarez took the wrong route to the ball and gave Burger another life.

Before all the drama, both clubs were mired in defensive struggles. The Marlins were the first victims, committing two errors to give the Mets an early lead.

The first came from Jon Berti in the third inning, who bobbled the ball in left field after Pete Alonso singled. The error turned a clear single into a double and gave the Mets a runner in scoring position.

With Alonso in scoring position, the Marlins made a second consecutive error that resulted in a run. Francisco Lindor came to the plate and dribbled a ball up the left-field line. Braxton Garrett could have put the ball in his back pocket and kept Alonso on the bases.

Instead, he threw it down the right-field line and allowed Alonso to score to give the Mets a 1-0 lead. The speedy Lindor would have beat out the throw and was rewarded with a single.

The inning could have, and frankly should have, been worse for the Marlins. Lindor stole third base after the error and started dancing down the line. Garrett picked up his left leg as if he was going to throw over, but then stopped his motion, jumping in the air and throwing the ball toward the plate.

What should have been a balk was called a disengagement. Instead of being up 2-0, Lindor stayed at third, leaving Álvarez with the chance to drive him in. The rookie catcher couldn’t get the job done, striking out and leaving Lindor at third.

The Mets were also victims of mental mistakes and gave away the go-ahead run in the bottom of the fifth. With two runners on base and nobody out, Edwards laid a perfect bunt down between Ronny Mauricio and Joey Lucchesi.

Lucchesi picked up the ball and threw it to third base in one motion. It would have been a nice play with the exception that nobody was covering third. The throw went down the line, scoring Berti to extend the Marlins’ lead to 2-1.

Outside of his mental error in the fifth inning, Lucchesi had another impressive outing for the Mets. He allowed two earned runs (three total), six hits, two walks, and struck out five in 5 2/3 innings.

Lucchesi’s start raised his ERA from 2.83 to 2.88 this season. Since coming back up, he has allowed two runs and struck out nine in 12 2/3 innings.

The only two earned runs Lucchesi allowed came in the third and sixth innings. Soler and Josh Bell recorded back-to-back doubles for the first run in the third, and Garrett Hampson singled to drive in Burger for the second run in the sixth.

Gott To Be Better

Trevor Gott gave up the go-ahead single to Jake Burger to lose the game. Since being traded to the Mets, he has pitched to a 4.62 ERA in 25 1/3 innings. He also owns a 1.500 WHIP.

On Deck

The Mets will send Kodai Senga to the mound to wrap up their three-game series with the Marlins. Senga has dominated the majors in the month of September, pitching to a 1.47 ERA with 27 strikeouts in 19 innings. The only starter with a better ERA in September is Blake Snell (1.00).

Each of Senga’s starts is a must-watch for any fan.

The Marlins have not announced a starter for Wednesday’s matchup.

First pitch for Wednesday’s game is scheduled for 6:40 p.m. The game will be televised on SNY and FS1, and can be listened to on WCBS 880.