NBA

Kidd’s clutch shot, Anthony’s 45 help Knicks top Nets

Jason Kidd celebrates the emotional win. (Anthony J. Causi)

Jason Kidd beat the Knicks plenty of times during his days with the Nets. Last night, the greatest player in New Jersey Nets history turned the tables on his old team in its new home.

Kidd took a pass from a driving Raymond Felton and buried a 3-pointer — drawing a foul on Jerry Stackhouse in the process — with 24.1 seconds left to give the Knicks a thrilling 100-97 victory over the Nets in the second installment of the Battle of the Boroughs in front of a divided sellout crowd of 17,732 inside Brooklyn’s Barclays Center.

Carmelo Anthony led the Knicks with 45 points.

“I penetrated, saw his man took a step, two steps actually, inside the paint and said, ‘It was a wrap,’ ’’ said Felton. “Shot that pass right to him.

“That man’s 5-for-7 for the game. You leave him, I’m going right to him.”

Kidd failed to seal the game, though, when he missed the ensuing free throw, setting up a frantic final 24 seconds. Nets coach Avery Johnson opted not to call a timeout, instead leaving the ball in the hands of his star point guard, Deron Williams.

After Williams brought the ball down, the Nets moved it around the perimeter before it settled into the hands of Gerald Wallace on the right wing, who launched a potential, game-tying 3-pointer with 6.9 seconds remaining.

Wallace’s shot looked good, but after sliding around the rim the ball came out.

“It felt pretty good,” Wallace said with a wry smile. “I was like, ‘Damn.’ ”

But Joe Johnson managed to corral the missed shot, and fired it out to Williams, who was ready to shoot on the opposite wing. Williams released it with Kidd flying out to contest it, but the shot missed long, sending the Nets to their fifth straight loss and evening the season series between the crosstown rivals at a game apiece.

“It felt good,” said Williams, who finished with 18 points and 10 assists. “It was a good look.”

The first time these teams met two weeks ago, the crowd was slightly in favor of the Nets, a massive improvement over the 80-20 or 90-10 advantage the Knicks would enjoy at Nets home games in New Jersey. But, at best, it was 50-50 last night, with the Knicks fans often making their presence felt.

But it was the Nets who raced out to a 17-point lead in the first half on the backs of a blistering 12-for-19 shooting performance (63 percent) in the first quarter. But the Knicks slowly began to claw their way back into the game on the back of Carmelo Anthony.

Anthony, whom Williams called an MVP candidate before the game, played like one. He finished the game 15-for-24 — making one difficult shot after another — and finished 5-for-7 from 3-point range.

“It feels great to win back here in Brooklyn,” said Anthony, who was born in the borough. “I can’t lie. When you’re out there and you get that energy … for me personally, that’s a great feeling.

“That’s something great for me to hear.”

After carrying the Knicks back into the game, Anthony took over for much of the fourth quarter, including scoring six straight points before Kidd’s game-winner.

“He made some tough shots, but that’s what great players do,” Avery Johnson said. “He’s having an MVP-type season. Even when we tried to get over to him for the double-team, he was shooting the ball quickly before our coverage got there.”

The Knicks tied the game for the first time in the fourth quarter with 4:01 left on another Kidd 3-pointer, setting up what turned into a wild final few minutes.

Following Kidd’s jumper, referee Bill Kennedy waited several seconds on the ensuing possession before he incorrectly called Andray Blatche for offensive interference. That was followed by Anthony scoring off an offensive rebound off his own miss to give the Knicks a 93-91 lead — their first of the final quarter.

The teams exchanged baskets from there, culminating with a floater from Joe Johnson with 1:11 remaining to tie the game at 97.

From there, Tyson Chandler tipped out a miss by J.R. Smith, setting up Kidd’s heroics and sending the Nets to another loss.

“I don’t really know what you take from these games now,” Wallace said of the Nets, who face Toronto tonight. “We’ve got to figure something out. We’re in a ditch and the dirt’s getting higher and higher, and we’ve got to figure out how we get out of this ditch before we’re covered up.”

tbontemps@nypost.com