Just when the Nets had witnessed a fresh, dynamic reminder of the power of Jeremy Lin’s presence, they suddenly had to deal with his absence again. And still they kept on going. They didn’t give up after they saw the man who had given them a spring in their step limp off the court with another left hamstring strain. They turned his loss into their most stirring win of the season.

Despite their three blowout losses last week, despite trailing the Hornets by 14 points in the second half Monday night at Barclays Center, despite losing Lin, they celebrated like crazy after Lin’s replacement, reserve point guard Randy Foye, made a three-pointer at the buzzer for a 120-118 victory the Nets won’t soon forget.

“When he went out, it was just like, ‘He went out, so the next man has got to step up,’ ” said Foye, who has been out of the rotation lately for a team that was torched by the Raptors, Warriors and Cavaliers last week. Not only that, but Foye said he blamed himself for not switching away from Kemba Walker to cover big man Cody Zeller on an offensive rebound basket that put Charlotte ahead 118-117 with 2.3 seconds left.

He added that the final play was set up for Brook Lopez, who had scored 10 of his 21 points in the fourth quarter. But Foye said Walker — the elite point guard who was held to 15 points by an energized Nets defense — was caught between switching and staying with his fellow point guard. Foye saw just enough of an opening, went up and hit a shot that sent the Nets into a frenzy. The coach was in the middle of the frantic pile.

“I’m just thrilled with our group,” Kenny Atkinson said. “We went through some tough times recently. So to come back and get a win like this . . . and the way we got it is special.”

Truth be told, it looked as if the Nets were on their way to another one-sided defeat early in the first half. But Lin kept driving and shooting with a sense of purpose. It was as if he refused to let this one get away.

advertisement | advertise on newsday

“J Lin was out there leading us. His energy brought us to a whole new level,” Lopez said. Lin had 17 points and four assists in 22 minutes.

Seventeen is a conspicuous number. That is how many games Lin missed recently with the same injury that he suffered Monday night.

This time he grimaced on a drive 1:10 into the third quarter but kept playing. When he missed a layup later, he was unable to make it down the court for defense and signaled for a timeout with 7:47 left in the quarter.

Atkinson later said there was no update on his condition. Anyway, he and the team were focused on all of the things that went right, such as Bojan Bogdanovic being kept out of the starting lineup and responding with 26 points (“I played the last couple of games bad,” he said), Sean Kilpatrick hitting big shots and finishing with 23 points, and Foye having been scoreless until the final tick of the clock.

“We played a great game,” Bogdanovic said. “We’d be pretty disappointed to lose it.”

The Hornets knew what to expect, having seen Lin’s determination every day when he was on their squad last season.

“I think his strengths are their strengths, so he enhances what they want to do,’’ Charlotte coach Steve Clifford said before the game. “He wants to play with pace. They’re first in the NBA in pace; they’re 10th in fast-break points.”

Atkinson was optimistic before the game about finally having all 15 of his players healthy and available for the first time all season. “We’ve been trying to find the right lineup, the right combinations,’’ he said. “You do need a certain sample size to see a group together. We’re still trying to grasp what our best lineups are and when to put in our best lineup.”