Orlando made just nine of 28 3-point attempts, but got a pivotal 3 from J.J. Redick in the final 10 seconds.
"Our perimeter guys all shot the ball very, very poorly tonight, so trying to decide who you're going to have down there as the last man wasn't an easy call," Magic coach Stan Van Gundy said. "(Redick) knocked in a big one right there."
That the Magic even got to that point with a chance to win was due in large part to Howard, who made 16 of 20 field goal attempts, including four dunks.
"It wasn't a great shooting night for me and a couple of other guys," Redick said. "Fortunately, Dwight carried us offensively for most of the night."
Howard scored 16 points in the first half and added 13 more in the third quarter, when he made five of six shots.
"My teammates gave me the ball in the right position to score," Howard said. "(Toronto) really didn't help much so I had a lot of room to be effective."
Watching Howard dominate inside was difficult for Toronto to take.
"It's frustrating seeing him dunking the ball like that over and over," Raptors center Aaron Gray said. "Obviously the 3-point ability is their strength and that was our focus tonight."
Redick scored 13 and Jameer Nelson had 11 for the Magic, who have won five of seven and nine of 12.
DeMar DeRozan scored 23 for the Raptors, who have not won back-to-back games since road wins over Phoenix and Utah on Jan. 24 and 25. Toronto has gone 6-13 since.
"I feel for our guys because they are putting themselves in a position to win," Raptors coach Dwane Casey said. "I see fight every night."
Orlando led 68-63 to begin the fourth, but Toronto cut the gap to one with a jumper and two free throws from Bayless. Anderson answered with a 3, then completed a three-point play to put the Magic up 74-67 with 9:03 left.
The Magic later had a 7-0 run over a 2:20 span, including a pair of baskets by Howard and a fast-break layup by Jason Richardson, to take an 87-78 lead with 2:58 to go.
Jose Calderon stopped the run with a 3 and, after Howard missed a pair of free throws, DeRozan banked in a shot to make it 87-83.
Howard missed four more from the line before Bayless was fouled with 31 seconds left. He made them both, cutting it to 87-85, but Redick drained a 3 right in front of the Toronto bench with 9 seconds remaining, restoring Orlando's five-point cushion.
"J.J. is a guy we really rely on for those big moment shots," Anderson said. "We really trust him and he knocked it down once again."
Toronto called time and drew up a play for Calderon, whose 3 made it 90-88 with 6 seconds left. Redick was fouled and sealed it by making both.
"J.J. is a great shooter," Howard said. "He hit a tough 3 and then he stepped up to the line and hit two big free throws."
Howard had 10 points and seven rebounds in the first quarter as Orlando led 23-20. Three of his five baskets came on dunks.
Howard scored six more in the second and Anderson had nine rebounds as the Magic overcame a 14-point quarter by DeRozan to take a 43-38 lead into halftime.
Toronto used a 9-0 run in the third to take its first lead since 12-9 of the opening quarter. Leandro Barbosa's 3-pointer with 6:26 left gave the Raptors a 51-49 edge.
Howard led the Magic back, scoring 11 points over the next 5½ minutes, including an alley-oop dunk from Redick, as Orlando took a five-point edge into the final quarter.
Van Gundy walked out of the locker room with a Raptors team doctor following the game and was overheard complaining of chest pains. Asked how he was feeling when he returned, Van Gundy answered "I'm not doing real well." ... Toronto was without forward Amir Johnson (right knee). Ed Davis started in Johnson's place and C Solomon Alabi was activated. ... Magic F Quentin Richardson (strained right Achilles) missed his fourth straight game. ... Howard made four of 14 free throw attempts. ... Orlando is 18-3 when leading after three quarters, including 8-0 on the road. ... Hedo Turkoglu matched a season high with nine assists. ... Toronto played home games on consecutive nights for the second time this season and 10th time in team history.