DETROIT - The Detroit Red Wings scored a flurry of goals after giving up one.

Dylan Larkin and Brad Richards scored 45 seconds apart midway through the second and Gustav Nyquist added one late in the period, helping Detroit build a cushion it needed to beat the Calgary Flames 4-2 Sunday night.

"Our second period was the way we have to play hockey to be successful," Red Wings coach Jeff Blashill said.

Detroit got the puck out of its end quickly, forechecked hard and created turnovers to keep pressure on the Flames in the pivotal period.

The Red Wings needed the comfortable lead because Calgary cut into it.

Dougie Hamilton's goal with 3:59 left pulled the Flames within a goal.

Justin Abdelkader, though, scored an empty-net goal with 30 seconds left in the game to seal the victory.

"Maybe we don't have enough energy to get on top of teams and forecheck and backcheck," Hamilton said.

Petr Mrazek made 26 saves for the Red Wings, who were winless in their previous three games, and the goaltender was fortunate to have some shots hit posts behind him.

"Saved us when we needed him to," Red Wings captain Henrik Zetterberg said.

Karri Ramo stopped 31 saves for the Flames, who have lost two straight after winning seven in a row.

Calgary's Dennis Wideman broke a scoreless tie in the first period.

Wideman's goal ended the team's five-game stretch without a power-play goal. The Flames, who score on an NHL-low 10 per cent of their power plays, had scored just two goals with a man advantage in 52 chances over 15-plus games before his goal.

Zetterberg was able to play one game after having a lower-body injury, but defenceman Jonathan Ericsson was unable to bounce back from the upper-body injury he had in Friday's shootout loss to Vancouver. Blashill said he didn't know if Ericsson would be cleared to play Tuesday at home against New Jersey.

Larkin made it 1-all 7:46 into the second period, scoring off a rebound and ending a five-game stretch without a goal, after the Flames failed to clear the puck.

Less than a minute later, Calgary was casual with the puck in its end and it was costly because Richards was able to shoot the puck through traffic and into the back of the net to put Detroit up 2-1.

"Turnovers flip the momentum," Calgary coach Bob Hartley said.

The Flames pulled Ramo to add an extra skater during a 4-on-4 situation with four-plus minutes left and it paid off with Hamilton's goal.

"Petr held us in the first, then we got going a bit," Blashill said. "At the end, it got a little crazy."

Detroit, which has struggled to keep late leads this season, did enough to win after going 0-1-2 in the previous three games following an 8-0-4 run.

"If you can put a stop to it and come out with a game like we had, it definitely helps and builds confidence," Red Wings forward Riley Sheahan said.

NOTES: Calgary, which surged over .500 with its recent winning streak, fell to 5-11-2 on the road. ... The Red Wings scratched C Tomas Nosek and D Xavier Ouellet after recalling for the game from the AHL to add depth.