ORLANDO, Fla. -- Rookie guard Victor Oladipo had 30 points, a career-high 14 assists and nine rebounds to lead the Orlando Magic to a 129-121 double-overtime victory over the New York Knicks on Friday night.

Teammate Arron Afflalo had 32 points, but he left with 2:23 remaining in the second overtime because of a sprained right ankle.

Knicks forward Carmelo Anthony had 44 points and 11 rebounds, scoring all eight points for the Knicks in the second overtime. Anthony made 16 of 28 shots from the field. He was coming off a 42-point effort in Wednesday's victory.

Oladipo, in his finest NBA game, also scored eight points in the second overtime, including two three-point plays that won the game.

The Magic (17-40) snapped an eight-game losing streak to the Knicks (21-34), who are struggling to stay in contention for a playoff berth.

The Magic missed a chance to win at the end of the first overtime when center Nikola Vucevic missed a short, heavily contested shot just before the buzzer sounded. Vucevic missed the final shot, also heavily contested, at the end of regulation.

Knicks center Tyson Chandler lost two points with 1:04 remaining in the first overtime, with the score tied at 113, when his dunk was waved off by officials because of his own basket interference.

The Magic, sparked by Oladipo, outscored the Knicks 27-20 in the fourth quarter and forced the overtime after trailing by as many as 14 points in the third quarter.

The Magic tied the score at 106 with a jumper by Afflalo with 39 seconds remaining in regulation. Anthony committed a turnover when he stepped out of bounds with 22 seconds remaining, leaving the Magic with a final opportunity. Vucevic missed on a running, fallaway jumper just before the buzzer sounded, sending the game into overtime.

The Magic took their first lead of the second half at 98-96 when forward Maurice Harkless hit a short jumper with 5:27 remaining, capping a 10-0 burst that included a 3-pointer by guard E'Twaun Moore.

The Knicks answered with a basket by Anthony and 3-pointer by guard Raymond Felton for the 101-98 lead, but it was far from over.

The Knicks led by as many as 14 points in the third quarter, but the Magic cut the deficit to seven when Oladipo scored the last four points of the quarter.

Anthony had 19 points and seven rebounds at halftime when the Knicks led 60-53. The Knicks closed the second quarter with a 19-6 run, including the final six by Anthony.

Afflalo also had a big first half with 18 points, including 14 in the first quarter when he hit all three of his 3-point shots. The Magic led by as many as seven points in the second quarter.

The Knicks shot 57.5 percent from the field (23 of 40) in the first half.

The game marked the return of Knicks veterans Amare Stoudemire and Metta World Peace. Stoudemire, who had missed the last game with a sore left knee, scored 10 points. World Peace did not play in the previous three games because of a coach's decision, but he was no factor on Friday night.

NOTES: The Magic bought out the contract on Friday of veteran F Glen Davis, who started 43 games this season and averaged 12.1 points and 6.3 rebounds. Davis was scheduled to make $6.6 million next season, the last year on his contract. The intent is to get more playing time for the young players. "It was best for the team, and best for Glen," Magic general manager Rob Hennigan said before the game. "It's important for the young guys to get more opportunity. This change was necessary." ... The Magic are expected soon to sign F Adonis Thomas to a 10-day contract to fill the roster spot. Thomas is playing for the Springfield Armor of the Developmental League. ... With Davis gone, the Magic went small on Friday night, moving rookie G Victor Oladipo back into the starting lineup for the first time since Feb. 3. Arron Afflalo slid from guard to forward. ... The Knicks moved F JR Smith into the starting lineup on Friday night in place of Iman Shumpert, who sprained his left knee on Wednesday and is expected to be out for two weeks. ... The Magic honored former player Penny Hardaway at halftime. Hardaway, who helped lead the Magic to the NBA Finals in 1995, had not been in Orlando for a game since leaving the NBA in 2007.