ORLANDO, Fla. — Last week the Orlando Magic left the Boston Celtics’ home court having just received one of their most demoralizing losses of the season.

The Magic returned the favor Tuesday night but the Celtics made them work for it.

Tobias Harris scored 19 points and the Magic hung on to beat the Celtics, 100-95. Nik Vucevic and Kyle O’Quinn each added 18 points as Orlando ended a four-game losing streak.

Orlando looked to be in control in the second half and led by as many as 27 points, but that was trimmed to three in the closing minutes.

The Magic were outscored 35-15 in the fourth quarter but never trailed.

“We just got away from what we were doing throughout the whole game and they capitalized off that,” Harris said. “But we got it together toward the end of the game and came out with the victory.”

Tyler Zeller led the Celtics with 22 points and 10 rebounds. Avery Bradley added 20 points and Kelly Olynyk 14.

Boston looked sluggish offensively for most of the night, connecting on just 38 percent of its field-goal attempts.

Orlando was up 25 entering the final period but fell apart in the closing minutes, relying on outside shots and turning the ball over five times.

The Celtics, who couldn’t find the basket in the first half, scored from all over the court in the final period.

Olynyk’s 3-pointer got Boston within 90-87 with 2:34 to play, but the Magic were able to cobble together enough free throws in the final two minutes to preserve the win.

“Obviously in the fourth quarter they got on their heels a little bit, but it’s a lot easier to be a team coming back than the team with the lead,” Celtics Coach Brad Stevens said.

The Magic were the beneficiaries of an inept first-quarter shooting performance by the Celtics. Boston connected on only one of its first 17 field-goal attempts in the period and finished the quarter 2 of 22.

“We’ll continue to improve,” Magic Coach Jacque Vaughn said. “What I do love about this group is we lost multiple games in a row and we kept a team to 30 points in the first half.

“So while you can definitely look at some negative, we’ll pull some positive out of this also.”

NOTES: The Celtics set season lows for points in a quarter (9) and points in a half (30). …Orlando reserve guard Willie Green, who was inactive Sunday against the 76ers with flu-like symptoms, was activated. … Celtics guard Jameer Nelson received a noticeable ovation from Magic fans when he was introduced in the pregame. Nelson later acknowledged them with a wave while a video tribute played on the scoreboard during a timeout. Nelson played with Orlando from 2004-14 before being waived this past summer. He left second in regular-season games played for Orlando at 651, behind only Nick Anderson (692).