ORLANDO, Fla. -- This winning thing has become a habit for the Brooklyn Nets — and apparently no deficit is too large to overcome lately.
D'Angelo Russell matched his career high with 40 points and the Brooklyn Nets came back after trailing by as many as 21 points to beat the Orlando Magic 117-115 on Friday night.
"If the media wasn't in here, we'd be screaming and yelling, playing music and dancing," said center Jarrett Allen after the Nets' 16th win in 21 games. "That was so great. It's not every day you see a team coming back from 21 points down. ... When you start winning games like this, it definitely changes your personality."
Russell's 3-pointer with 27.1 seconds left put the Nets up for the first time since they went ahead 2-0 in the game's first minute. After missed free throws by both teams left Brooklyn with a two-point lead, Evan Fournier missed a shot in the lane that would have tied it for Orlando.
The Nets also rallied Wednesday night from an 11-point fourth-quarter deficit in a 145-142 overtime victory at Houston.
"We've got a great group of guys with the same goals and that's what we're starting to notice," said Russell, who shot 8 of 12 from 3-point range and did not attempt a free throw. "We're all buying in and we're all hanging on each other's success. It's a great feeling."
The Nets made 19 of 46 3-point shots and are now in sixth place in the Eastern Conference after being 10 games under .500 in early December. At 24-23, New Jersey is above .500 after 47 games for the first time since the 2012-13 season.
Aaron Gordon scored 23 points for Orlando, and Nikola Vucevic added 16 points and 17 rebounds. The Magic, who have lost six of eight, shot 50 percent but made only 10 3-pointers.
Spencer Dinwiddie scored 18 of his 20 points in the second half for Brooklyn.
The Magic made 11 of their first 15 shots in the second quarter to take a 58-37 lead. Russell made five 3-pointers in a span of less than four minutes to shoot the Nets back in the game, and they held Orlando to one field goal over the final 4:50.
"I thought Orlando dominated us for 95 percent of the game," Nets coach Kenny Atkinson said. "I thought in the fourth quarter we started to play some defense and D'Angelo was huge. We didn't play a great game, but we pulled it out anyway."
Dinwiddie and Shabazz Napier sparked a second-half rally after the Nets had fallen behind 86-68 midway through the third quarter.
Orlando led 100-89 after Gordon hit a 3-pointer early in the fourth quarter, but the Magic couldn't hit shots at the end.
"I thought our last four shots were good," Magic coach Steve Clifford said. "If you're going to win a game like this, you're going to make a couple of them. And the ball didn't go down."
GORDON SITS OUT FINAL 9:19
Gordon went to the bench with a stiff back with 9:19 remaining and never returned. "I'm going to just rest as much as I can tonight and see how it feels tomorrow," he said. "Hopefully I can go (against Milwaukee). We'll see how it goes when I wake up, but right now it's tough to move it."
It was Orlando's first loss in eight games in which Gordon scored 22 points or more.
Nets: The Nets have won six straight close games (decided by three points or less). ... Russell scored the Nets' final 19 points of the first half. ... Atkinson called a timeout 81 seconds into the game after two Orlando dunks.
Magic: Rookie C Mo Bamba had nine points and four rebounds after missing four games with a sore left foot. ... Vucevic's 10th rebound gave him 5,000 for his career. ... The Magic distributed 13 grants worth a total of $1.2 million to 16 organizations in a pregame ceremony.
Nets: At home against Sacramento on Monday afternoon.
Magic: At home against Milwaukee on Saturday night.
More AP NBA: https://apnews.com/NBA and https://twitter.com/AP—Sports