The Mets were six outs away from surviving the Dodgers and leaving Citi Field on Sunday night with a critical series win.

Then the bullpen pulled its old tricks, and the Mets flew to Colorado with their season on life support.

In the rubber match of a series with high-end pitching matchups and high-end implications for the home team, Zack Wheeler delivered a gem. But it promptly went to waste, as Justin Wilson gave up the tying run in the eighth and Seth Lugo allowed the go-ahead run to score in the ninth as the Mets fell to the Dodgers in crushing fashion, 3-2.

The Mets (77-72) have been left for dead before this season, only to rally back into contention. But after Sunday’s loss, they dropped to four games back of the final playoff spot with 13 games left. It may finally be a hole too deep to climb out of with time running out on the season.

“When their backs are against the wall, they do special things,” manager Mickey Callaway said. “They’ve proved that time and time again and I think they’re going to continue to prove that. We gotta go take care of business in Colorado. Tough place to go on a tough travel night. There’s no excuses. We gotta wake up, come out, swing the bats and get the job done.”

The Dodgers (97-54), who arrived in Queens having already clinched the NL West, were largely shut down by Wheeler, who departed with a 2-1 lead after seven innings. But they got to Wilson in the eighth, when pinch-hitter Jedd Gyorko led off with a walk, was balked to second, went to third on a wild pitch and scored on an RBI double by Chris Taylor.

Gyorko then delivered the dagger in the ninth with a two-out, two-strike single off Lugo to drive home Kiké Hernandez for the 3-2 lead. Hernandez had doubled just out of the reach of center fielder Juan Lagares two batters earlier.

“I made my pitch and [Gyorko] found a hole,” Lugo said. “That’s where I was trying to go with it. That happens. That’s baseball.”

The Mets did not get any help all weekend from the Pirates, whom the Cubs swept by a combined score of 47-15 to keep their grip on the second wild card by one game over the Brewers and four games over the Mets. After the loss, the Mets flew to Colorado, where they will begin their final road trip (six games, seven days) of the year against the Rockies and Reds.

“We got a lot of fight in this team, so I wouldn’t count us out yet,” Wheeler said.

In one of his best starts of the year, Wheeler allowed just one run over seven innings while striking out nine and walking none. He did some of his best work under pressure as the Dodgers went just 2-for-14 against Wheeler with runners on base.

Brandon Nimmo provided the Mets’ only offense on the night with a two-run triple to the right-field corner for the 2-0 lead in the second inning.

The Dodgers got a run back in the fourth inning on a two-out RBI single by Corey Seager.

Wheeler then worked his magic in traffic, bringing the crowd to its feet in the sixth and seventh inning by stranding three runners. But soon after he was gone, so was the Mets’ lead, with their season left hanging in the balance.

“It’s disappointing, but they’re a good team over there,” J.D. Davis said. “It doesn’t really matter if the bullpen gives up one run or two runs, we still gotta score some runs and give them some relief.”

Purchase event tickets to The Amazin’ 1969 New York Mets: A World Championship for the Ages presented by The Paley Center for Media and New York Post. Enter promo code: NYPOST to unlock tickets only available for Post readers.