The outcome was decided in the third period, but signs of the Wild’s demise started to pop up much earlier.

There was an ineffective four-minute power play, an untimely penalty and busted coverage in front.

These lapses were minimized while the Wild scrambled to recover but, in the end, they were exposed as helping put in motion a 5-4 collapse to the Flyers on Tuesday night at Xcel Energy Center — a gut-wrenching blow to a wobbly Wild squad that has won only once in its past seven games while its hold loosens on a playoff spot.

VideoVideo (00:53): Coach Bruce Boudreau discusses the 5-4 loss to the Flyers Tuesday.

“There’s just times in the game where we’ve got to find a way to get it done,” goalie Devan Dubnyk said.

After securing 3-1 and 4-3 leads, the latter in the third, the Wild couldn’t hold on — getting upended by a plucky Philadelphia squad playing its second game in as many nights.

Winger James van Riemsdyk completed the comeback 15 minutes, 31 seconds into the final period on the power play after the Flyers tied the score at 4 on a blistering shot by captain Claude Giroux at 6:30 during a poor line change by the Wild.

“When the puck didn’t even go past their blue line, and you’re making a change at that time of the game, pretty unforgiveable,” coach Bruce Boudreau said.

Earlier in the third, at 2:06, defenseman Jared Spurgeon capped off a three-point effort when he nudged the Wild ahead on a rising shot, but not growing that edge was costly — just like it was in the first two periods.

“We have it on our stick, and we just don’t put it in,” Boudreau said.

The Flyers opened the scoring only 2:54 into the first when a shot from defenseman Ivan Provorov deflected off defenseman Nick Seeler and behind Dubnyk, but the Wild rebounded.

Winger Zach Parise lifted his team-leading 23rd goal over Flyers goalie Anthony Stolarz from along the goal line on the power play at 8:58 and only 1:47 later, winger Luke Kunin put back a carom off defenseman Shayne Gostisbehere’s stick.

At 13:28, Kunin put the Wild up 3-1 when he buried a Joel Eriksson Ek pass.

But the Wild struggled to extend that momentum in the second while playing without forwards Victor Rask and Matt Hendricks. Both left injured and did not return.

An errant high stick by rookie Jordan Greenway clipped winger Jason Zucker late in the first, drawing blood, but the Flyers were called for the double-minor.

That gave the Wild 2:12 of power-play time to start the second, but the team couldn’t convert and finished the game 1-for-6.

“If we score in the second there, a couple, I think that puts the game away,” Spurgeon said.

The Flyers, meanwhile, used a five-hole tip by van Riemsdyk at 8:42 after an Eric Fehr penalty to cut into the Wild’s cushion.

And then 5:15 later, Philadelphia evened it at 3 when center Sean Couturier directed a Travis Sanheim pass through the crease after both gained positioning on defensemen Anthony Bitetto and Jonas Brodin.

VideoVideo (01:05): Sarah McLellan recaps the 5-4 loss to the Flyers in her Wild wrap-up.

That set up a decisive third, a battle the Flyers won when they scored their second goal on the power play in four tries to seal a result that could be traced back to a destructive sequence of errors earlier in the game.

Dubnyk totaled 21 saves, while Stolarz had 35.

“Maybe we were playing content and happy with the 3-1 [lead] and stopped working,” Kunin said. “You can’t do that with any team in this league. When you stop working and not playing that full 60, it’s going to cost you.”