Lindgren stunned Sabres netminder Aaron Dell by taking a pass from Mika Zibanejad and rifling the puck into the net for his second goal of the season at 19:59. Adam Fox had passed the puck to Zibanejad after it emerged from a scrum in the corner as the final seconds ticked away.
Lindgren's heroics came after the teams scored three goals each in a wild second period, including four goals in an 82-second span.
"It was sloppy in the second but we found a way to get two points at the end, Rangers coach Gerard Gallant said. "We were putting pucks to the net."
Lindgren's goal - just the fourth of his career -- ignited a frenzy among fans at Madison Square Garden, where overtime seemed all but a certainty against the Sabres.
"It seemed like there was a battle in the corner and the puck got to Foxy who kicked it out to Mika and obviously a great play by him," the 23-year-old Lindgren said. "It was a great win."
Chris Kreider, Jacob Trouba, Kaapo Kakko and K'Andre Miller all scored for the Rangers. Alexander Georgiev had 14 saves, and was replaced by Igor Shesterkin, who had four saves in the third.
"Just a coach's decision," Gallant said about switching goalies. Shesterkin earned the win to improve to 9-3-2 on the season.
The Sabres have lost eight of their last 10 games. Rasmus Asplund, Vinnie Hinostroza, Tage Thompson and Rasmus Dahlin all scored for Buffalo, and Dell had 31 saves.
"Great atmosphere, great energy in the building and lots of momentum swings," Sabres coach Don Granato said. "We did a good job until about two seconds left. We didn't react well enough and that's disappointing."
Asplund opened the scoring at 15:53 of the first with a power-play goal. Kreider tied it for the Rangers with this team-leading 13th goal of the season, whipping the puck past Dell with less than a minute left in the first.
Hinostroza put the visitors ahead with an unassisted goal at 2:26 of the second. Rangers defenseman Trouba tied the contest at 8:03, poking a loose puck past Dell at 8:03 of the period.
Kakko then scored his third goal in his last four games with eight minutes left in the second to give the Rangers a 3-2 lead, which lasted less than a minute before Thompson tied the game with his team-leading sixth goal.
Dahlin then beat Georgiev with a shot from the point 15 seconds later to put Buffalo ahead 4-3. Miller continued the scoring barrage with another tying goal 17 seconds after Dahlin's.
"We tightened up in the third," Granato added. "We need to be more assertive."
The Rangers were coming off 2-1 loss at Toronto on Thursday. Their scheduled Saturday visit to Ottawa was postponed because of a Covid-19 outbreak on the Senators.
Gallant said Lindgren's winning goal is extra satisfying because of how much he contributes defensively for the resurgent Rangers, who are third in the Metropolitan Division after 18 games.
"A great play by him, a smart play by him," Gallant added. "He blocks shots. He does everything for us at the back end. When he gets a chance to score a big goal like that, it's great for our team."
Artemi Panarin had three assists for the Rangers, leaving the 30-year-old forward eight points shy of 500 in his career. ... Sabres forward Victor Olofsson played for the first time since Oct. 31 when he was injured against Los Angeles. ... Sabres defenseman Henri Jokiharju remained sidelined. He hasn't played since he was struck in the ankle by a puck during the season opener against Montreal on Oct. 14. ... The Rangers scratched defenseman Nils Lundkvist and Libor Hajek plus forward Greg McKegg. ... The Sabres scratched goaltender Craig Anderson, defenseman Christian Wolanin and forward Arttu Ruotsalanien.
Rangers: At New York Islanders on Wednesday night.
Sabres: Host Columbus Blue Jackets on Monday night.
Lindgren wins it for Rangers with a second left in regulation
Ryan Lindgren scores just before the horn sounds as the Rangers beat the Sabres 5-4 in regulation.