Ayres, who works as a Zamboni driver for the Toronto Marlies of the American Hockey League, was forced into action midway through the second period after Carolina's James Reimer and Petr Mrazek were injured. The Hurricanes were leading 3-1 when the 42-year-old Ayres took over.
Warren Foegele scored twice, Martin Necas had a goal and an assist, and Lucas Wallmark, Nino Niederreiter and Sebastian Aho also scored for Carolina.
Alexander Kerfoot, Pierre Engvall and John Tavares scored for Toronto, which beat the Hurricanes 8-6 at home on Dec. 23. Kasperi Kapanen and Tyson Barrie each had two assists. Frederik Andersen made 43 saves.
Reimer started against his former team, but left just 6:10 into the first period with a lower-body injury after Toronto's Zach Hyman shoved a Hurricanes defenseman on top of him in the crease.
Mrazek came in, but also had to leave after a thunderous collision with Leafs forward Kyle Clifford while attempting to play the puck near the face-off dot in Carolina's zone in the second.
That forced Ayres, who was available to both teams, into action.
After a bizarre second period that saw Carolina score four times, give up two goals, lose Mrazek, and have Ayres enter the game, the Hurricanes made it 5-3 just 53 seconds into the third, jumping on a turnover and beating Andersen in tight.
Necas then made it 6-3 at 3:44 when he picked up a loose puck to finish off a chaotic sequence as boos rained down.
Carolina trailed 1-0 after the first, but tied it at 5:46 of the second when Wallmark scored off a scramble in front of Andersen. Niederrieter then blasted a one-timer on a power play at 9:43 before Foegele made it 3-1 at 10:49.
Mrazek made 14 saves in relief of Reimer, but left the game 30 seconds after Foegele's first goal. The Czech netminder lay on the ice for a few minutes before leaving.
And after a delay, Ayres emerged from the Hurricanes locker room sporting No. 90. He got a some warmup shots from his new teammates before getting thrown into the fray.
Aho made it 4-1 with Clifford in the penalty box for charging at 13:17, but Tavares scored on the first shot against Ayres through the pads 19 seconds later.
Engvall scored off a loose puck on Toronto's next shot against Ayres at 15:10.
The Leafs got a power play after that — fans at Scotiabank Arena screamed "Shoot!" almost every time a Toronto player had the puck anywhere near the Carolina goal — but the Hurricanes didn't allow anything through.
Ayres made his first save late in the second on Auston Matthews as Carolina led 4-3 through a wild 40 minutes.
Kerfoot capped a frantic first period with 35.1 seconds left when he scored his ninth of the season after Mrazek couldn't control a shot by Jake Muzzin.
In the first period, Zach Hyman shoved Hurricanes defenseman Jaccob Slavin into Reimer, earning an interference penalty. The Carolina goalie, who played for Toronto from 2010 to 2016, stayed in the crease after being looked at by a trainer, but left shortly thereafter.