Trailing by 11 at the start of the fourth quarter, the Cavs fought back and were down by two points following Jose Calderon's layup with 12.6 seconds left.
On the next possession, Irving (32 points) took the ball up the court and pulled up from well behind the 3-point arc to drain the game-winner with 0.7 seconds left.
Cleveland then sealed the triumph -- their season-best third straight win -- when Alonzo Gee stole Calderon's inbounds pass.
Amir Johnson led the Raptors with 18 points and 12 rebounds. Alan Anderson scored 17 points, Ed Davis had 16 points and nine rebounds, and DeMar DeRozan scored 15 for Toronto, which lost for the sixth time in eight games.