The Mets wanted to see how they would fare against better competition after resurrecting their season versus lowly opponents.

They got a pretty good answer Friday night, with one of their most dramatic victories of the season.

With the Mets trailing by three runs entering the bottom of the ninth, Todd Frazier tied it with a three-run home run and Michael Conforto won it with a long single for a 7-6 comeback win over the Nationals.

“I just happened to be the guy up last,’’ Conforto said of his late-game heroics. The win keeps them a half-game out of the second wild-card spot and moves them to 1¹/₂ games behind Washington for the first slot.

That’s what happens when you win 14 times in 15 games, which is the Mets’ best stretch over that span since 1990.

The winning rally started with a double from red-hot J.D. Davis against Nationals closer Sean Doolittle.

Wilson Ramos singled to center, sending Davis to third and bringing Frazier to the plate. Frazier drilled his 15th homer of the year inside the left-field foul pole, sending the Citi Field crowd into a frenzy.

Asked if he went to the plate trying to hit a homer, Frazier grinned and said: “Pretty much.”

While the rally came out of nowhere, it didn’t stun Frazier or his teammates.

“You don’t feel like you’re out of a game when you’re on a run like this,’’ the third baseman said.

Joe Panik, in his Mets debut after signing with the team earlier in the day, followed Frazier and got his first hit of the game, but was erased when pinch-hitter Juan Lagares bunted into a fielder’s choice.

After Jeff McNeil flied to right, Amed Rosario singled to left and Conforto drilled a single over Adam Eaton in right for the game-winner.

Conforto was mobbed by his teammates around second base and had his jersey ripped off by Pete Alonso.

The late dramatics overshadowed what had been an interesting battle between Marcus Stroman — in his first home game as a Met — and Stephen Strasburg.

Stroman and the Mets went down 3-0 in the top of the fourth, but the lineup bailed him out in the bottom of the inning with three runs of their own thanks to back-to-back homers by Alonso (a two-run shot) and Davis.

Mickey Callaway opted to keep Stroman in the game into the seventh, despite the righty having thrown 102 pitches through six.

The move backfired, as Stroman walked Trea Turner.

Justin Wilson came in and whiffed Eaton, but Anthony Rendon followed with a two-run homer to left to give Washington a 5-3 lead.

Strasburg, coming off a disastrous outing against Arizona — when he tied a career-worst by allowing nine runs in 4 ²/₃ innings — was much improved Friday and retired the first nine batters he faced.

Stroman got off to a fast start, as well. He struck out seven of eight batters in the early going, but he gave up an RBI triple to Rendon and then a two-run shot to Juan Soto to make it 3-0.

The Mets finally got a baserunner when Strasburg walked McNeil to start the bottom of the fourth. With two out, Alonso drilled his 38th homer of the season to left to make it 3-2. It was the fourth consecutive game in which the first baseman has homered. Davis followed with an opposite-field homer to tie the game at 3-3.

Both teams wasted chances in the sixth, before the Nationals took the lead an inning later.

They added a run on a Robert Gsellman wild pitch in the top of the ninth that scored Turner from third.

But the shaky Washington bullpen couldn’t hold the lead, as the Mets scored multiple runs off Doolittle for the third time this year.

“It felt like the playoffs with the stadium packed,’’ Conforto said. “We fed off that. We’ve got to keep it going. … I think we’ve done a good job the past couple weeks of taking care of business, beating teams we know we should beat. That’s what good teams do.”

On Friday, they found a way to beat another good team.

“Right now, we’re firing on all cylinders,’’ Conforto said. “Our confidence is just building with each win.”