Mitchell Marner had a goal and two assists and John Tavares supplied three assists for Toronto. Morgan Rielly added a goal and an assist, Ron Hainsey chipped in an empty-net goal while Frederik Andersen made 26 saves.
Defenseman Nick Jensen scored two goals and Dylan Larkin had the other for the Red Wings. Jimmy Howard turned aside 23 shots.
Toronto outshot Detroit 11-6 in the first period but the teams headed to their locker rooms tied at 1-all.
The Red Wings took advantage of a rare four-on-one break to score the first goal. Jensen finished it from the right circle after a feed from Darren Helm.
Detroit got caught in a line change when Toronto evened the score at the 15:48 mark. Marner slid the puck to Rielly, who one-timed it over Howard's shoulder from the right circle.
Toronto took the lead two minutes into the second period. Marner came from behind the Wings' net unchecked and scored in front.
The Wings failed to get a shot on goal for nearly 13 minutes. They were outshot 15-5 during the second.
Jansen scored off his own rebound to make it 3-2 midway through the period. Andersen made a nice pad save but the goal was left wide open when the puck caromed back to Jansen, who has scored three of six career goals against Toronto.
Matthews scored on a power play to give the Leafs a little breathing room. Larkin scored during a scramble in front of the net with 6:04 remaining to bring Detroit back within one. The empty-netter ended all suspense.