The Mets were oh-so-close to snapping a brutal seven-game losing streak that had pushed their playoff hopes to the brink.

Alas.

Tyler Rogers, Edwin Diaz and shoddy late-inning defense turned a two-run eighth-inning lead into a painful 3-2 loss to the Rangers — the Mets’ eighth straight defeat — in front of 41,752 at Citi Field on Saturday.

“It’s not easy right now, especially when you’re not able to finish the job in a game where you felt like you had it, and then before you know it, you’re behind,” Mets manager Carlos Mendoza said.

The Mets (76-73) have gone 31-49 since June 13. They are a half-game ahead of the Giants, 1 1⁄2 games ahead of the Reds and two games ahead of the Diamondbacks in the battle for the NL’s third wild card.

Rookie righthander Brandon Sproat , in

See Full Page