Toronto is 14-0-0 when scoring first this season. The Maple Leafs (19-9-3) are 10-1-1 in their past 12 games, since a 9-2 home loss to the Nashville Predators on Nov. 18.
Anaheim's seven-game winning streak ended.
Toronto was outshot 42-27.
"I think we were opportunistic tonight," Maple Leafs coach Randy Carlyle said. "It was not one where we are going to say we'll bottle that and take it to the bank and say tomorrow we felt good about ourselves.
"From an execution standpoint, from a defensive standpoint and from an energy standpoint, we weren't on our game. We didn't seem to have any energy in our forecheck. We were receiving the game and we stopped skating … but we won."
Asked about being undefeated after scoring first, Carlyle smiled and said, "You've got to like it. I don't know what to say. We'll just keep riding the wave if we can."
"We were excited for these two games and to get four points against those two teams is really good for us," Lupul said.
Maple Leafs center Tyler Bozak scored 15:12 into the first period. Left wing James van Riemsdyk drove to the net from the corner and tried to jam the puck past goalie Frederik Andersen, who made the save. Bozak scored his 12th of the season on the rebound from the slot.
Toronto made it 2-0 at 1:31 of the second period when Lupul accepted a pass from defenseman Korbinian Holzer at the faceoff circle and snapped a high shot past Andersen on the short side. It was Lupul's seventh goal of the season.
The Ducks pulled within 2-1 with a shorthanded goal at 13:13. Center Ryan Kesler got the puck inside the Toronto blue line and took off with defenseman Sami Vatanen on a 2-on-1. Kesler hit Vatanen with a pass, and he broke in alone, snapping a shot past Toronto goalie Jonathan Bernier for his ninth of the season.
Left wing David Booth restored Toronto's two-goal lead at 4:37 of the third period when he connected on a wraparound, his first goal with the Maple Leafs, and then 51 seconds later Nazem Kadri deked Ducks defenseman Mark Fistric with a perfectly executed toe drag and whipped a high shot past Andersen to make it 4-1.
The Ducks (21-7-5) pulled Andersen, replacing him with Ilya Bryzgalov, who was making his first appearance for Anaheim this season in his second stint with the Ducks.
Kesler got the Ducks back within 4-2 with his 11th of the season at 8:35 of the third. He drove to the net with Kadri in pursuit, took a pass from Kyle Palmieri, and redirected the puck past Bernier.
Toronto right wing Phil Kessel made it 5-2 with a snap shot past Bryzgalov for a power-play goal at 15:23. Kessel scored again, his 17th of the season, on a breakaway at 18:17.
"We were right in the hockey game for most of it," Ducks captain Ryan Getzlaf said. "They are an opportunistic team; they found ways to score goals when we didn't and turned the tide of the game."
Getzlaf credited Bernier with playing a solid game for the Maple Leafs but was not pleased with the way the Ducks played in the third period.
"I'm upset with the way we finished the game," Getzlaf said. "I didn't think that we finished properly. Those are tough games when you are in an emotional game. I don't want our group to think that is OK to finish the way we did tonight."
Lupul made two good defensive plays in the third period. On the first, he dove to knock the puck off a Ducks stick on a scoring chance, and on the other he blocked a hard shot. Lupul said he and his teammates are committed to playing a better 200-foot game.
"We're always going to be known as a skating and offensive team," Lupul said. "We're seeing a little bit different team from years past, obviously with the fourth line [contributing] so much and playing a bit better team defense. The penalty-killing has been better too. I certainly see a team that is getting more confident in close games and learning how to close them out."