Vincent Trochek had a goal and an assist, and Braden Schneider and Adam Fox also scored for the Rangers, who won for the second time in seven games (2-4-1) and snapped a four-game skid (0-3-1) at home. Artemi Panarin had two assists, Lafreniere added one, and Igor Shesterkin made 25 saves.
''We stepped it up in the third. We really wanted this win'' said Mika Zibanejad, who assisted on Lafreniere's go-ahead goal as part of a new line combination. ''From the first shift, you could tell. It was time for us to show it. We got the win ... It's a lot better than standing here talking about another loss.''
Jordan Kyrou had a goal and an assist, and Pavel Buchnevich, Vladimir Tarasenko and Ryan O'Reilly also scored for the Blues, who have lost six of seven since a seven-game winning streak. Jordan Binnington had 18 saves.
St. Louis led 4-3 entering the third period before Miller tied it with his first goal of the season at 4:48.
Lafreniere's go-ahead goal came at 8:16 as he tipped a long shot by Zibanejad past Binnington for his fourth.
''It's good to score one,'' Lafreniere said. ''I will try to keep going with consistency in my game ... Our third period was really good. We can score when we work hard.''
After Trocheck took a hooking penalty with 6:21 remaining, Kreider scored on a short-handed breakaway 25 seconds later. Kreider's 13th goal of the season sparked a loud celebration of relief from the crowd at Madison Square Garden, where the Rangers had squandered leads in three of the four defeats.
''It felt good to give us an extra cushion going into those last couple of minutes,'' Kreider said. ''Every game is a must win. It's up to us to be resilient and we were resilient today.''
The Blues had won all seven games this season when leading after two periods.
''We played two great periods, controlled the game. But in the third, with the game on the line, we were tentative,'' Blues coach Craig Berube said. ''You've got the lead, you've got to go play with confidence but right now we're not a confident hockey team ... We didn't push enough.''
The Rangers opened the scoring when Schneider fired a puck past Binnington with 2:46 left in the first period. It was his third.
The Blues tied it 50 seconds later as former Ranger Buchnevich fired a shot that bounced off Fox's skate and in for his ninth. It was the second game back at the Garden for Buchnevich who was traded to St. Louis in July 2021 after parts of five seasons with the Rangers.
Buchnevich has 14 points in his last 10 games (eight goals and six assists) while the player the Rangers got in exchange - Sammy Blais - has yet to score a goal in 38 games for New York.
The Rangers went ahead 2-1 with 28 seconds remaining in the first on a power-play goal by Fox, his seventh of the season.
Tarasenko then tied it again for the Blues just 12 seconds into the second. It was his seventh.
Trocheck then put the Rangers ahead 3-2 at 1:07 with his ninth goal.
Kyrou scored on a power play to tie it at 11:04 with his team-best 10th, and O'Reilly gave St. Louis its first lead of the night with his eighth 91 seconds later. Kyrou had an assist on O'Reilly's goal, giving him 18 points in his last 15 games.
Blues: At the New York Islanders on Tuesday night.
Rangers: At Vegas on Wednesday night.
AP NHL: https://www.apnews.com/hub/NHL and https://www.twitter.com/AP-Sports
Copyright 2023 STATS LLC and Associated Press. Any commercial use or distribution without the express written consent of STATS LLC and Associated Press is strictly prohibited.