TORONTO -- James van Riemsdyk scored a hat trick, and the Toronto Maple Leafs defeated the Dallas Stars 6-5 in a shootout at Air Canada Centre on Wednesday.
The Maple Leafs trail the Boston Bruins by seven points for second place in the Atlantic Division and are 14 points ahead of the fourth-place Florida Panthers.
[WATCH: All Stars vs. Maple Leafs highlights]
"I just try to get to the good spots on the ice where you can score goals and I'm playing with some smart players that know how to get the puck to those areas," said van Riemsdyk, who has 29 goals, one ahead of Auston Matthews for the Toronto lead. "I got some good puck luck tonight and was able to capitalize on my chances."
The Stars took over the first wild card into the Stanley Cup Playoffs from the Western Conference but were not satisfied with earning one point after leading 4-2 following the second period and 5-4 before Patrick Marleau's tying goal with 16 seconds left in the third. He deflected a shot from Mitchell Marner in the slot to make it 5-5.
Video: DAL@TOR: van Riemsdyk records third career hat trick
"That was a big point to give away," Stars center Tyler Seguin said. "I mean we obviously needed it a lot more than them. It's disappointing."
Nazem Kadri scored, and Tyler Bozak and Marner scored in the shootout for the Maple Leafs (41-22-7), who won their 11th straight home game, the most in their history.
Seguin, Jamie Benn, Radek Faksa, Remi Elie and Brett Ritchie scored, and Kari Lehtonen made 26 saves for the Stars (38-26-7), who trail the Minnesota Wild by two points for third in the Central Division and are one point ahead of the Colorado Avalanche, who are tied with the Anaheim Ducks (82 points) but hold the second wild card because they've played two fewer games.
"It's tough, we gave that lead away in the third," Stars forward Devin Shore said. "We said all the right things in the room, how we wanted to keep it pushing because I thought our second period was really good. It stings. At this stage, it's all about results. We didn't get it done so we've got to turn it around."
Video: DAL@TOR: Marner nets wrister to clinch SO win
Frederik Andersen allowed three goals on 20 shots before leaving with an upper-body injury at 10:25 of the second period.
"I haven't asked yet but it sure didn't seem like much," Toronto coach Mike Babcock said. "He played after he got hurt so I don't know exactly. I'll find out more in a bit."
Babcock said he was not sure if Andersen would travel to Buffalo for the game against the Sabres on Thursday. Curtis McElhinney made 13 saves in relief and did not allow a goal on two shootout attempts.
"[McElhinney has] been great all year," Babcock said. "Obviously he was good in the shootout, gave us a chance, got us a big win. We're trying to crawl our way into the playoffs, we need points [and] we don't have enough so we've got to find ways to win."
Ritchie one-timed a pass from Seguin past McElhinney at the side of the net at 13:18 of the third period to put Dallas up 5-4.
Video: DAL@TOR: Benn bangs home Seguin's nice pass
Van Riemsdyk cut Dallas' lead to 4-3 at 5:13 of the third period. He scored again at 10:43 on the power play when he one-timed a pass from Marner to tie it 4-4.
Seguin put the Stars ahead 3-2 at 4:30 of the second period when he got to his own rebound and put a shot between Andersen's pads. Elie one-timed a cross ice pass from Devin Shore at 14:03 to make it 4-2.
The Maple Leafs went up 1-0 at 4:28 of the first period when Lehtonen misplayed the puck in front of the net, allowing Kadri to one-hand it into an open net. Van Riemsdyk made it 2-0 25 seconds later when he put a rebound in from the slot at 4:53.
Benn scored at 14:29 when he one-timed a pass from Seguin over Andersen's right shoulder to make it 2-1. The Stars tied it 2-2 at 16:01 when Faksa deflected a point shot from Greg Pateryn.
Goal of the game
Marleau's goal with 16 seconds remaining in the third period.
Video: DAL@TOR: Marleau tips in Marner's shot to tie it late
Save of the game
McElhinney's save on Benn at 2:32 of overtime.
Video: DAL@TOR: McElhinney snags Benn's strong slapper
Highlight of the game
Elie's goal at 14:03 of the second period.
Video: DAL@TOR: Elie finishes Shore's feed on the backdoor
They said it
"We came back and won the hockey game about three times but we ran out of gas. I felt for the players, to go down 2-0 in this building and mount that type of comeback and play that well and really outplay them badly for two periods, to get scored on late is obviously disappointing for everybody." -- Stars coach Ken Hitchcock
"The heart rate spikes, I think that would be interesting to see what that looks like on a heart rate monitor. It certainly goes up and the adrenaline starts pumping but once the first shot is taken, you kind of settle in." -- Maple Leafs goaltender Curtis McElhinney on entering the game without any notice
Need to know
Babcock said Matthews, who has missed the past seven games with a shoulder injury, will make the trip to Buffalo. ... The Maple Leafs gave up a two-goal lead and came back from two goals down to win for the fourth time in their history. They won for the fourth time this season after trailing by two in the third, the most such wins in the NHL this season.
Stars: At the Ottawa Senators on Friday (7:30 p.m. ET; RDS, TSN5, FS-SW+, NHL.TV)
Maple Leafs: At the Buffalo Sabres on Thursday (7 p.m. ET; MSG-B, TSN4, NHL.TV)
Video: van Riemsdyk, Marner lift Maple Leafs to 6-5 SO win