New York Mets' Jay Bruce, right, hugs Yoenis Cespedes (52)...

New York Mets' Jay Bruce, right, hugs Yoenis Cespedes (52) after hitting a two-run home run in the fifth inning during a baseball game against the Miami Marlins, Wednesday, Sept. 28, 2016, in Miami. Credit: AP / Lynne Sladky

MIAMI — Chaos still lurks on the horizon in the form of a three-team tie for the National League’s two wild cards, a headache that the Mets would do well to avoid.

The only preventive measure is to keep winning.

So, after beating the Marlins, 5-2, on Wednesday night, the Mets made the nightmare scenario a bit more unlikely. With a Cardinals’ loss to the Reds later in the evening, the Mets’ magic number was reduced to just two.

The Mets (85-74) could clinch a spot in the NL wild-card game as early as Friday against the Phillies, who reportedly held a team meeting on Wednesday night to prepare themselves to play the role of spoiler this weekend.

“If we win, we’ll be fine,” said rightfielder Jay Bruce, who homered for the second time in as many days. “We can’t worry about what everyone else is doing.”

James Loney also homered for the Mets, who have won five of their last seven games. Meanwhile, rookie righthander Seth Lugo powered through early trouble, holding the Marlins to two runs on five hits in 5 1⁄3 innings.

Jeurys Familia extended his single-season franchise record by nailing down his 50th save, becoming just the 13th big leaguer to reach that plateau, and the first to be born in the Dominican Republic.

“For me, it’s something very important, representing my country,” said Familia, who went on to thank his coaches and teammates through the years.

Familia ensured that the Mets won two of three games in a series rife with emotion. They had lost Monday’s series opener, the first game played by the Marlins after the death of their brilliant young ace, Jose Fernandez. But the Mets found the resolve under delicate circumstances to refocus on the race at hand.

“We had games to play that were very meaningful for us,” manager Terry Collins said. “I thought the guys after Monday night realized they had to go out and play.”

The Cardinals and Giants both play on Thursday, when the Mets will be off, a welcome reprieve after a draining three days in Miami.

“The mental fatigue we’ve just gone through the last three days, tomorrow is a welcome day off,” said Collins, who nevertheless saw plenty of reasons to be encouraged.

With first baseman Lucas Duda unable to play because of back stiffness, Loney blasted a two-run homer to tie the game in the second after the Marlins jumped to a 2-0 lead on Martin Prado’s two-run homer.

In the fifth, with the Mets leading 3-2 on Jose Reyes’ RBI double, Bruce homered for the second straight day. His seventh homer since joining the Mets doubled as a sign that he may salvage what has been a miserable two-month tenure.

Lugo, meanwhile, shook off Prado’s homer to help the Mets win for the seventh straight time in one of his starts.

“This kid has come here and done nothing but save us,” Collins said.

For Lugo, fatigue has been a consideration of late. He downplayed his workload. but the Mets kept him on a pitch count on Wednesday.

After establishing a career-high 136 innings last season, the righty is already at 137 1⁄3 innings. That total may only climb if the Mets get into the playoffs, with Lugo set to play a prominent role in a rotation missing Matt Harvey, Jacob deGrom and Steven Matz.

“Seth might be getting a little bit on the tired side,” pitching coach Dan Warthen said before Lugo was pulled after only 82 pitches.

Of course, there is plenty of reason to be protective of Lugo (5-2), who lowered his ERA to 2.67. The 34th-rounder who has emerged as a surprise would next be slated to pitch on Monday — a potential tiebreaker game

Of course, the Mets would rather avoid their own version of October madness.

“If we win, we’re in,” Bruce said. “And we’re going to play whoever we’re going to play at our place and it’s going to be a lot tougher.”

SUBSCRIBE

Unlimited Digital AccessOnly 25¢for 5 months

ACT NOWSALE ENDS SOON | CANCEL ANYTIME ONLINE