NEW YORK (AP) Their big lead was gone and their hold on a playoff spot was in danger of following.
Instead, the Brooklyn Nets were saved by Brook Lopez's effort - his second one, actually.
Lopez's follow shot with 2 seconds left gave the Nets their fifth straight victory and a share of seventh place in the Eastern Conference, as they beat the New York Knicks 100-98 on Wednesday night.
The Nets blew a 16-point, second-half lead but escaped what could have been a crushing loss thanks to Lopez's work on the boards on their last possession.
''We're just finding ways to win ballgames,'' point guard Deron Williams said. ''We start off great and have some lulls. Tonight we had two, but at the end we buckled down and did what we had to do to win.''
Williams had 26 points, seven rebounds and seven assists in one of his best games of the season. And when he missed in the lane with the game tied at 98, Lopez tipped the ball once, then knocked it in on his second attempt.
''D-Will got a good look. He was being aggressive like he had been all night. I was right there around the rim and just tried to keep it alive,'' Lopez said.
Andrea Bargnani scored 22 points for the Knicks, who lost their eighth straight.
''It's tough, but we kind of put ourselves in a hole earlier in the game,'' Knicks forward Jason Smith said. ''It wasn't just that last play.''
The Nets swept the season series for the first time since going 4-0 in 2006-07, and they tied Miami at 34-40. The Heat own the tiebreaker after beating Brooklyn all four times.
The Nets won for the ninth time in 11 games, but barely held on after appearing to run out of gas on their second night of a back-to-back.
Lopez finished with 18 points, well below the dominant numbers he had put up recently during his run as East player of the week, but just good enough to keep the Nets ahead of Boston in the race for the conference's final playoff spot.
Cleanthony Early scored 14 for the Knicks, who were far more competitive than during most of their skid. He missed a 3-pointer that would have won it on the final possession.
The Nets had a 16-point lead late in the third quarter after a 3-pointer by Williams, whose only game with more points this season was when he had 29 against the Knicks in the Nets' 110-99 victory on Nov. 7.
A night after scoring 33 in the first quarter, the Nets came back with 30 more in this one and led by nine after one. They pushed it to 14 early in the second and there seemed to be little interest in the finale of this season's New York City series, the crowd at Madison Square Garden quiet and disinterested for most of the game.
That all changed when the Knicks opened the fourth quarter with a 17-7 run that brought them to 92-88 on Early's 3-pointer midway through the period. They later cut it to one but threw up consecutive airballs with a chance to take the lead, then finally tied it at 98 on Early's 3-pointer with 1:07 to play.
Nets: Williams' 18 points in the first half were his high for any half this season. ... Brooklyn rookie Markel Brown shook off a hard fall early in the game when he was fouled trying to catch a lob pass. He finished with 14 points.
Knicks: New York had lost two games by 31 points during its skid and three others by 16 or more.
BARGNANI ON THE BENCH
Despite scoring 22 points in 27 minutes, Bargnani sat the entire fourth quarter until coming in for the final possession.
''The guys that started that fourth quarter had taken it from 14 down to eight, down to six, down to four. They earned the right, I think, to finish the game,'' Knicks coach Derek Fisher said.
Nets: Host Toronto on Friday.
Knicks: Visit Washington on Friday.