Green caught Kyle Lowry's inbound pass with 2.3 seconds left, pulled up on the left side of the lane and hit a jumper with 0.5 seconds remaining, The Associated Press reported.
Orlando's Nikola Vucevic missed on a 67-foot heave as time expired.
Kawhi Leonard led Toronto with 18 points, and Pascal Siakam had 15. Serge Ibaka added 14 points and nine rebounds, and Green finished with 13.
Evan Fournier led the Magic with 27 points, 22 of them in the second half when he was about the only offense Orlando could generate. Aaron Gordon had 16 points, and Vucevic had 14 points and 18 rebounds for the Magic, who ended a three-game winning streak.
Fournier drove past Green for a tying dunk with 2.3 seconds left. The Raptors took a full timeout, and Green scored on the ensuing inbound.
Neither team had it going offensively for most of the game, especially in the fourth quarter.
The Magic missed 11 straight field-goal attempts in a four-minute stretch early in the period. Their only points were two free throws from Jonathan Isaac, but the drought didn't cost them much.
Toronto could only put together a three-pointer from Green and a layup by Jonas Valanciunas during that stretch to take an 80-77 lead.
The teams traded baskets from there until Ibaka drilled a jumper from the top of the key to put Toronto in front 91-89.
Toronto led by 18 during a first half when both teams struggled to find or maintain an offensive rhythm. The Raptors made enough shots to jump out to a 40-22 advantage in the middle of the second quarter, as Orlando labored under 30 percent shooting.