Nylander gave Toronto a 4-2 lead at 3:28 of the third period when he scored off the rebound of a Jake Muzzin shot.
"Maybe I've just been having the mentality to shoot a little more, I think," said Nylander, who has scored five times during the streak and has five goals and three assists during a six-game point streak. "Once you're scoring, you feel confident in your shot, so I think that's when I keep shooting the puck."
[WATCH: All Maple Leafs vs. Stars highlights]
After Alexander Radulov got Dallas within 4-3 at 6:26 with his second of the night, Andreas Johnsson scored into an empty net with three seconds left for the 5-3 final.
Johnsson, Auston Matthews and Tyson Barrie each had a goal and an assist for the Maple Leafs (27-17-7), who have won two straight and are 3-3-2 in their past eight games. Frederik Andersen made 31 saves.
"It was good," Maple Leafs forward Zach Hyman said. "We knew that we needed to start getting on the right side of games, especially coming off the break."
Video: TOR@DAL: Matthews goes top shelf on Bishop
The Stars (28-18-4) are 2-4-0 in their past six games. Ben Bishop allowed four goals on 33 shots.
"We just didn't play detailed enough," Dallas forward Andrew Cogliano said. "We knew what type of team they were. They play a puck-possession game and want to play offense.
"We've been in harder games in terms of physicality, but with teams like that, when you cheat a little bit and get into their style of game, that's when you lose."
Matthews gave the Maple Leafs a 1-0 lead at 12:18 of the first period when he scored with a high shot off a pass from Mitchell Marner, who had two assists. It was his 36th goal, one behind Boston Bruins forward David Pastrnak for the NHL lead.
"He puts himself in good spots," Toronto coach Sheldon Keefe said. "You saw today that Mitch gave him a puck in a great spot, and that's a world-class finish."
Denis Gurianov skated between Muzzin and Maple Leafs forward Alexander Kerfoot before beating Andersen with a shot from the right hash marks at 17:21 to tie the game 1-1.
"He can make plays at top speed," Stars coach Rick Bowness said. "A lot of guys sometimes with that top speed have to slow down a little to make a play or get a shot off. Denis doesn't have to do that, and that's a great skill."
Video: TOR@DAL: Gurianov splits defenders for pretty goal
Hyman got behind the Dallas defense and scored off a pass from Marner at 4:40 of the second period to make it 2-1.
Barrie scored with a slap shot that went in off Bishop's right pad to give Toronto a 3-1 lead at 11:58.
Radulov made it 3-2 at 19:02 when he scored from the left face-off circle off a cross-ice pass from Radek Faksa.
"Faksa made a good pass," Radulov said. "On the second one, [Mattias Janmark] did a good job on the forecheck, and I just tried to get in front of the net and be there, and it went in."
The Maple Leafs went 3-for-3 on the penalty kill, including after Jason Spezza was called for interference against Radulov at 12:55 of the third with Toronto leading 4-3.
Video: TOR@DAL: Barrie's shot deflects into the net
The Stars are 0-for-12 on the power play in their past four games.
"The power play needs to be a lot better," Bowness said. "It's as simple as that. They're not creating anything and not giving us any momentum. It's not more complicated than that."
They said it
"It was a hard game. They are a really good team. We had a big kill at the end, I think it was five minutes left or whatever it was. The last two minutes were a grind, and they pushed, but [Frederik Andersen] made a couple of huge saves. It was big to hold on there." -- Maple Leafs forward Zach Hyman
"We need to keep doing that. We're chasing in the standings. This is a [Stanley Cup] Playoff push right now, so we have to be sharp every game." -- Maple Leafs forward William Nylander
"We had enough chances tonight, got three goals, and they made some good saves. But [the offensive] end will take care of itself if we take care of our end, and we didn't do that tonight. We just weren't as committed to that tonight as we have been." -- Stars coach Rick Bowness
Video: Clutch Performance: Matthews has two points vs DAL
Need to know
The Maple Leafs have scored at least four goals in eight straight road games, the longest such streak in their history. ... Marner has 15 points (three goals, 12 assists) in the past 12 games. ... It was Radulov's third multigoal game of the season. His 15 goals are tied for the Stars lead with forward Roope Hintz, who did not play because of an upper-body injury. ... Spezza played 8:42 in his first game against the Stars since signing with the Maple Leafs on July 1, 2019, after five seasons with Dallas.
Maple Leafs: Host the Ottawa Senators on Saturday (7 p.m. ET; CBC, SN1, SNE, SNO, SNP, TVAS, NHL.TV)
Stars: At the New Jersey Devils on Saturday (7 p.m. ET; MSG+, FS-SW+, NHL.TV)
Video: Matthews, Barrie lead Maple Leafs past Stars