It was the stuff of slow-pitch softball games, with so many liners filling the hot air over Citi Field that even a relief pitcher couldn’t help but get a piece of the action.

In Thursday night’s showdown of the top two teams in the NL East, the Nationals and Mets totaled 16 runs and 27 hits, 14 for extra bases. The outburst included eight homers — a Citi Field record — two of them into the batter’s eye in center and two into the upper deck in right.

There were 310 pitches thrown, and though none of them came in underhanded, it seemed that way. How else to explain Nationals reliever Ollie Perez, the scorned former Met. He had been hitless in six years but nonetheless collected a pair of hits, including one that ignited a rally.

But once the dust settled on one of the weirdest nights in the history of Citi Field, the Mets emerged as 9-7 winners over the Nationals.

With three games left before the All-Star break, the Mets have cut their deficit in the division to three games.

It ended in controversy, as it was ruled that Jayson Werth slid into second base too late. It turned Daniel Murphy’s hard grounder — which shortstop Asdrubal Cabrera needed a lunge just to snag — into a critical double play that helped Jeurys Familia escape a jam. Bryce Harper struck out swinging to end the game.

The go-ahead homer came off the bat of the scorching Wilmer Flores, who blasted a three-run shot in the fifth to give the Mets their first lead of the game. Improbably, it stuck.

Flores didn’t even start the game. As expected, he was squeezed out of the lineup, with manager Terry Collins resolving to give playing time to Jose Reyes. Nevertheless, Flores entered the game on a double switch, then blasted his fifth homer since Sunday.

Twice, the Mets fell behind, only to tie it. In the fifth, the Nats went ahead 6-4. Only then did the Mets finally go ahead on Flores’ timely swing. The homer injected life into a vocal crowd on a sticky, humid night. They cheered for a curtain call, and Flores finally obliged.

Of course, it wasn’t the first time on a strange night that they had expressed their emotions.

For perceived crimes big and small, committed in the past and the present, they showered boos upon old friends (Murphy for knocking in three runs and Perez for, well, being Perez), old foils (Harper for blasting a mammoth homer) and old stars (Reyes for getting picked off first base even though he had homered earlier).

Murphy continued his one-man crusade for revenge. In 10 games against his former mates, he has 14 RBIs, the latest on a seventh-inning solo shot off Antonio Bastardo.

The Nationals clubbed three homers in the fourth inning alone against Bartolo Colon, who endured his worst start of the season. Clint Robinson and Anthony Rendon hit back-to-back solo shots after Harper’s towering blast.

The Mets answered with a pair of solo blasts of their own in the fourth courtesy of Reyes and Travis d’Arnaud. Cabrera smacked a solo shot in the sixth.

Curtis Granderson reached base in his first five plate appearances. He walked twice, singled twice and added a double.

Indeed, it was a brutal night for the pitchers.

Steady throughout the entire first half, Colon hit a wall, allowing a season-high six runs in 4 1⁄3 innings. But Lucas Giolito, the highly regarded Nationals prospect, had it worse. His big-league debut, also against the Mets, was cut short because of the rain. His second outing ended with a hail of liners.

He was chased after surrendering four runs and seven hits in 3 2⁄3 innings.