NEW YORK — The Brooklyn Nets worked overtime to pull out the opener of their new-look rivalry with the New York Knicks, winning 96-89 on Monday night to tie their city rivals for first place.

Jerry Stackhouse, wearing the No. 42 Jackie Robinson made famous in Brooklyn, hit the tiebreaking 3-pointer with 3:31 left in overtime as the Nets controlled the extra period of a playoff-like game that neither team led by more than seven.

Brook Lopez had 22 points and 11 rebounds, and Deron Williams added 16 points and 14 assists as the Nets improved to 7-1 in their new home and tied the Knicks atop the Atlantic Division at 9-4.

Carmelo Anthony had 35 points and 13 rebounds, but was only 10 of 16 at the free throw line. Tyson Chandler finished with 28 points and 10 boards, but no other Knicks player was in double figures.

Raymond Felton was just 3 of 19 from the field, but the Knicks had to stick with him with fellow point guard and former Nets star Jason Kidd out with back spasms.

The first matchup of Brooklyn and New York pro franchises since the Dodgers played the New York Giants on Sept. 8 1957, at the Polo Grounds was loud, energetic, and close throughout. Both teams played as if this meant more than the usual regular-season game.

The game was originally scheduled as the Nov. 1 season opener for both teams but was postponed after Superstorm Sandy, when much of the mass transit around the city was knocked out. Barclays Center sits above a major transportation hub, and without subways running many fans wouldn’t have been able to get here.

The Knicks have always been the clear No. 1 franchise in the area, even when the Nets had Kidd and were better, and the Nets have long believed the move to Brooklyn and the $1 billion Barclays Center would help them even things. Nationally televised and with more than 100 media members, this was easily their most anticipated game in years, but coach Avery Johnson denied that it meant more to the Nets than the Knicks.

“I think it’s just as important for them, because if we’re so much the new kid on the block and we’re trying to come in and gain some territorial rights, I think they’re going to try to do everything they can to push back, so I think it’s great,” Johnson said before the game. “I don’t think it’s so much of a Duke-North Carolina rivalry yet, but hopefully one day it’ll get there.”

Johnson estimated that games in New Jersey since he’d been with the Nets were an 80-20 fan split for the Knicks, and he hoped that would turn around Monday. It didn’t flip completely, but it seemed the home team’s fans made up about 60-65 percent of the crowd, the orange and blue that was long so ubiquitous harder to spot this time.

But Johnson made it clear the Nets needed to win the game, not just the crowd, for this to be a successful night, and his team was in great position up five with 4 minutes to play in regulation. The Knicks ran off eight straight to take an 84-81 lead with 1:40 left, but they wouldn’t score again. Lopez tied it with a free throw with 24 seconds remaining, and after Anthony missed a jumper, Williams was off on a long attempt before the buzzer.

Chandler dunked to open overtime, but the Nets answered with eight straight points, taking the lead for good at 89-86 on Stackhouse’s 3-pointer with 3:31 remaining before three straight points from Gerald Wallace, who finished with 16.

Both sides downplayed the idea of a rivalry — yet — leading into the game, but change was noticeable right from the start.

The Knicks were loudly booed during the announcement of starting lineups, with Anthony, a Brooklyn native whom the Nets tried to acquire before the Knicks did, receiving the type of loud, mixed response that usually goes to LeBron James.

There were dueling chants on one early possession, Knicks fans hollering “Defense! Defense!” while Nets supporters tried to drown them out with “Brook-lyn! Brook-lyn!”

The only time crowd support seemed unanimous was when local sports stars or celebrities, such as Jay-Z and Beyonce sitting near the Nets bench, were shown on the overhead scoreboard.

Notes: The Nets have won six straight at home for the first time since December 2003. They started 18-1 at home in 2002-03. … The teams meet three times in the next 3½ weeks. The Knicks return to Brooklyn on Dec. 11 and host the Nets on Dec. 19. … With Kidd out, the Knicks started Kurt Thomas — and actually got older. Kidd will turn 40 in March. Thomas, the league’s oldest player, turned 40 in October. … Anthony (10.9 ppg) and Lopez (7.9) entered as the NBA’s top two first-quarter scorers. Anthony had only four points, while Lopez scored eight.