The Mets scored five runs in the first inning Tuesday night, had a six-run lead after four and were heavily booed in the top of the seventh.

By the time the roller coaster had lurched to a stop after a tense ninth inning, manager Buck Showalter and the exhausted 37,109 on hand could exhale.

The Mets’ offensive explosion narrowly outweighed their pitching implosion in an 11-10, series-opening relief of a victory over the White Sox at Citi Field. The Mets’ strengths and weaknesses were on full display.

The White Sox, who had come all the way back from an 8-2 deficit, scored a run in the ninth against David Robertson and had the tying run on third base with two out.

But Robertson got the third out on a Tim Anderson fly out, and the wild ride was finally over.

The Mets (44-50) have either streaked or sunk throughout July.

They won six straight, lost four in a row and now have triumphed in two consecutive games.

They have 11 more games before the Aug. 1 trade deadline arrives, and the Mets’ bats at least have shown they are capable of a hot streak — even if their pitching problems nearly negated the offensive promise.

Francisco Alvarez celebrated the first of his two home runs against the White Sox on Tuesday night.
Charles Wenzelberg / New York Post

Francisco Alvarez hit two home runs and combined with Brett Baty and newcomer DJ Stewart, who hit one each, to club an estimated 1,675 feet worth of homers.

The Mets’ bats awoke after they had scored just four runs in three games against the Dodgers.

The game seemed over after four innings, at which point the Mets were ahead, 8-2.

But the inconsistency of their rotation, the deficiency of the underbelly of the bullpen and the misery of their defensive decision-making conspired to turn a laugher into a nail-biter.

Carlos Carrasco, who gave up four runs in 4 ²/₃ innings, was poor.

Grant Hartwig followed from the bullpen and pitched well, but he handed the game to Trevor Gott, who nearly handed it to the White Sox.

D.J. Stewart reacts to his solo home run against the White Sox at Citi Field on Tuesday.
Charles Wenzelberg / New York Post

Gott came on in the seventh inning with the Mets leading 11-4.

Four batters later, the score was 11-8 and he was pulled to raucous boos.

The recent pickup from the Mariners entered with two men on base and one out and induced a slow chopper to third baseman Baty, who threw too late to second base (instead of going to first), and thus and got no one out.

With the bases loaded, Jake Burger drilled a two-run double and Yasmani Grandal followed with a two-run single. Loud jeers filled the ballpark during a game in which the Mets were leading by three runs.

After Gott faced four batters and recorded zero outs, Brooks Raley entered and allowed a run on a wild pitch.

But Raley struck out Zeby Zavala and got Andrew Benintendi to fly out, and the Mets clutched their slim lead the rest of the game. Adam Ottavino and Robertson, who just barely got his 13th save, restored a semblance of order in the eighth and ninth.

Brett Baty celebrates his solo home run against the White Sox on Tuesday at Citi Field.
Charles Wenzelberg / New York Post

But it was the first inning that loomed largest.

The Mets have been the worst first-inning club in baseball and entered play with 26 runs in 93 first innings. Atlanta’s Ronald Acuña Jr. himself has scored 30.

But a five-run first appeared to nearly put the game away.

The Mets forced Lucas Giolito, who had been excellent for the past two months, to throw 35 pitches and feasted on the righty for 3 ²/₃ innings.

Most encouraging in the initial frame was that Alvarez, who hit a two-run home run, and Baty homered back-to-back, which might not mean much this season, but could portend well for the next handful.

Francisco Alvarez homered twice in the Mets’ win.
Corey Sipkin for the NY POST

The 21-year-old Alvarez, who started the season at Triple-A, leads all major league catchers with 18 home runs. The only catcher in his age-21 or younger season with more was Johnny Bench, who smacked 26 in 1969.

Baty, who has struggled to hit the ball in the air this season, has taken longer to develop but has shown flashes nonetheless.

The third baseman followed Alvarez by drilling a 425-foot dinger to center, just outside the Home Run Apple, for just his second homer in his past 42 games.

His bat has shown flashes, even if his defensive issues flashed, too.

Trevor Gott is removed from the game in the seventh inning.
Charles Wenzelberg / New York Po

Against the White Sox (40-56), Baty’s bat wasn’t the only one to break out. Jeff McNeil slapped a pair of RBI singles, one to left-center and one to right.

Tommy Pham, who had gone 3-for-27 in his past eight games (during which he nursed a groin injury), reached base four times in five plate appearances and stroked an RBI double.

Francisco Lindor reached twice, including an RBI double.

Stewart drilled his first Mets home run in his seventh at-bat for the team. Alvarez carried an offense that drew seven walks.

All over the Mets’ lineup were reasons to believe they could turn their season around.

But on the mound, there were plenty of reasons to believe hope is beginning to expire.