BUFFALO -- The Detroit Red Wings are within sight of their 23rd consecutive trip to the Stanley Cup Playoffs.
Helm broke a 1-1 tie 3:33 into the third period by firing a rebound past Buffalo goaltender Matt Hackett. Legwand made it 3-1 when he skated in to the right of Hackett and snapped a wrist shot over his shoulder with 4:14 remaining for his 14th goal of the season and fourth as a member of the Red Wings.
"He's got a good head for the game. He knows what it's about," Detroit forward Johan Franzen said of Legwand. "That was nice. It was good to see him get one."
Datsyuk hit the empty net in the final seconds after rookie Zemgus Girgensons' second goal of the night got the Sabres within 3-2.
Jimmy Howard stopped 25 shots for the Red Wings. Hackett stopped 33 shots.
With the win, the Red Wings (38-27-14) have 90 points and own the first wild-card position in the Eastern Conference, one point ahead of the Columbus Blue Jackets, who beat the Phoenix Coyotes in overtime.
Detroit coach Mike Babcock reached a personal milestone with his 414th victory in Detroit, passing Jack Adams for the most in franchise history. But he's more concerned with the Red Wings' road game against the Pittsburgh Penguins on Wednesday; one point in that game will assure Detroit of a berth in the playoffs, where they could see Pittsburgh in a first-round series.
"I don't spend a whole lot of time thinking about that," Babcock said of passing Adams. "I know we've got a game in Pittsburgh [on Wednesday]. We're going to enjoy this tonight and we'll get ourselves ready to go tomorrow. … If we do what we're supposed to do and they do what they're doing then we could meet in the playoffs. The reality is it's an important game [Wednesday]."
Detroit needs to earn one point in its final three games to clinch a playoff spot. The Red Wings' game starts about a half-hour before the Blue Jackets visit the Dallas Stars.
"It's one big step in the right direction," Howard said of beating the last-place Sabres. "Now we've just got to find a way to get a point or two points there tomorrow night. We've got to find a way to keep it rolling because you want to feel good going into the playoffs."
After a scoreless first period, Girgensons gave the Sabres a 1-0 lead 1:31 into the second. Girgensons was tied up in front of the net with Red Wings defenseman Danny DeKeyser in front of the net when Cody Hodgson fired a pass that Girgensons deflected past Jimmy Howard.
The Sabres had a chance to put the Red Wings in 2-0 hole when they had 1:51 of 5-on-3 power play time after a holding call on DeKeyser and a delay of game penalty to Justin Abdelkader. The Red Wings killed off both penalties, partly thanks to a big save from Howard against Sabres defenseman Rasmus Ristolainen.
"I thought it was huge," Howard said. "It was a great all-around effort by everyone and I was able to get a pad on the second shot there."
Red Wings defenseman Brendan Smith made it 1-1 at 12:28 of the second period. Smith took a cross-ice pass from Franzen on a 3-on-2 break and beat Hackett for his fifth goal of the season.
"Coach, he said there's a fine line where you've got to get up [in the play] but at the same time, you've got to make sure if there's a turnover you can get back," Smith said. "It's an in-and-out kind of thing and you've got to choose your chances and obviously I was fortunate to choose the right chance there."
Helm put the Red Wings ahead to stay with his 12th goal of the season. He collected the rebound of Kyle Quincey's shot and snapped a wrister past Hackett. It was his fifth goal in five games and third against the Sabres this season.
"He's huge for us," Franzen said of Helm, one of the team's fastest skaters, who has missed much of the season with injuries. "He's been good for us for many years. The speed he's got, the workload he can carry - we're a little dependent on that because there's not many players like him and we're really happy to have him when he's healthy and can play like he can right now."
Legwand's goal made it 3-1, but Girgensons' second goal of the night with 2:11 to play cut the Red Wings lead to 3-2. Girgensons dangled around the defense and beat Howard for his eighth goal of the season.
"One thing with Girgensons, he plays the game right," Sabres coach Ted Nolan said. "If there's one thing our team can learn, it's just watch the way he plays all the time. Whether he scores two goals or not, he's by far our best player on the ice. Why? Because he plays the game right. He plays both ends of the ice. He competes. He plays with some passion and all those things that good players do. He was great tonight."
Datsyuk hit the empty net with 4.3 seconds remaining for his 17th of the season. Datsyuk played in his third game since he returned from a knee injury that cost him 16 games.
"After this [injury] happened in early December I still tried to make it happen after the Olympics," Datsyuk said. "I tried to make a better decision this time and now it feels better."