NEW YORK — Curtis Granderson’s upbeat personality aided the Mets in navigating a difficult day at the ballpark.

A couple of big swings in extra innings helped, too.

Granderson hit a solo home run with two outs in the 12th inning after also connecting for a tying shot in the 11th, lifting New York over the Minnesota Twins 3-2 on Saturday night, hours after it announced star right-hander Jacob deGrom is likely done for the season.

The Mets moved into a tie with San Francisco atop the NL wild-card standings, with St. Louis two games behind them.

Granderson is the first Met ever to homer twice in extra innings in the same game, according to ESPN Stats and Info. He was in a 1-for-26 slump before his first shot.

“He never gets down,” manager Terry Collins said. “He’s never down. He’s the same guy every day. He’s dangerous.”

Granderson pulled a 3-2 pitch from left-hander Ryan O’Rourke (0-1) down the right-field line to win it, getting mobbed at home plate by teammates.

After Minnesota’s Byron Buxton hit a soaring homer for a 2-1 lead in the 11th, Granderson tied it 2-all leading off the bottom half against closer Brandon Kintzler.

Granderson’s second homer was the 201st by the Mets this season, breaking the team record set in 2006. It was his 28th home run this year and third career game-ender, including one on May 27 against the Dodgers.

DeGrom was scratched from his scheduled start Sunday and will probably miss the rest of the year because of an injury to the ulnar nerve in his right elbow.

“Obviously to miss a guy like that in the rotation is going to be tough for us,” Granderson said. “But we’ve had some great guys step in even in the time he’s been gone.”

Collins said the Mets will turn to a “plethora” of relievers to get through Sunday’s game against the Twins.

“I don’t know what the lineup is going to look like tomorrow,” Collins said. “We have a lot of guys that are tired and a lot of guys that are banged up.”

The Mets moved a season-high 10 games over .500 and have won 10 of their last 13. Nine of New York’s last 14 wins have come after trailing, and it has won six straight against the Twins dating to 2010.

Josh Edgin (1-0) pitched a scoreless 12th and got his first victory since June 1, 2014.

Twins starter Ervin Santana struck out nine, walked two and allowed four hits over seven scoreless innings.

Rookie Seth Lugo labored through five innings of four-hit ball to again support the Mets’ decimated rotation. He walked four but stranded them all, allowing his only run on a homer by Eddie Rosario in the fourth.

HAIRY SITUATION

Mets general manager Sandy Alderson announced deGrom’s prognosis hours before New York began giving away Jacob deGrom Hair Hats at the gate.

DeGrom has been out since Sept. 1 because of elbow pain. The 2014 NL Rookie of the Year felt fine while throwing a bullpen Friday but sensed a twinge after tossing a baseball in from the outfield during batting practice about 15 minutes later.

DeGrom will need surgery but has not decided whether he will wait until the end of the season. Regardless, the 28-year-old will be ready for spring training.

BUXTON’S BREAKOUT

Buxton’s homer was the latest sign that the former hyped prospect may be finding his way in the majors. Since being recalled Sept. 1, Buxton is batting .333 with six homers and 15 RBIs, a huge spike from his .193 average and 16 RBIs in 63 games earlier in the year.

“I think he’s had to deal with a lot in terms of the up and down and expectations,” manager Paul Molitor said. “And he’s just kind of learning to trust his ability a bit more.

TC ON NYC

Collins began his postgame media conference by sending his “prayers and best wishes” to victims of an explosion in Manhattan’s Chelsea neighborhood Saturday night. The blast left 29 injured.

“They’re in our hearts and prayers tonight,” Collins said. “It kind of brings things back to reality.”

TRAINER’S ROOM

TWINS: Rosario injured his left hand diving into first base trying to beat out a grounder in the 10th inning. He was replaced in left field by Logan Schafer. Molitor said “it didn’t look too good.”

Mets: LHP Steven Matz threw a 30-pitch bullpen and could return soon after already missing a month with left shoulder tightness. … 1B Lucas Duda was activated off the disabled list prior to the game. He missed nearly four months recovering from a stress fracture in his lower back. To make space, the Mets transferred LHP Jonathon Niese to the 60-day disabled list.

UP NEXT

Gabriel Ynoa gets the start in what should be a bullpen game for New York. Kyle Gibson (6-9, 5.08) will throw for the Twins.