Dwyane Wade scored 28 points and James almost had a triple double, but the Heat had trouble putting away a team that has one of the five worst records in the NBA.
Toronto was within four points with a minute remaining when James headed to the basket for a layup. He missed the attempt, but tipped in the rebound for a six-point cushion and the Raptors did not score again.
James had 23 points with 13 rebounds and eight assists. Chris Bosh scored 25 points in Miami's 10th win in 11 games.
Toronto was trying to win back-to-back games for the first time since the first week of December. Andrea Bargnani led the Raptors with 38 points.