PHILADELPHIA — Wayne Simmonds just had to tap the puck over the blue line but couldn’t. Then Andrew MacDonald fanned on a clearance.

Patrice Bergeron pounced on the extra chances, tying it for the Boston Bruins with 3.8 seconds left in regulation and leaving the Philadelphia Flyers stunned.

It took Jakub Voracek’s pep talk and Claude Giroux’s acrobatics to finally give Philadelphia a crucial win.

Giroux scored his second goal with 1:21 left in overtime and the Flyers recovered for a 4-3 victory on Sunday to inch closer to returning to the playoffs after a year’s absence.

“The play at the end of the game is a play that can’t happen. We all know that,” Flyers Coach Dave Hakstol said of the stick-handling mishaps in the final seconds of regulation. “Take that puck and just push it out to the neutral zone.”

Voracek implored his teammates to stay focused heading into overtime. Then he sprung Giroux on a breakaway, and the captain faked out goaltender Anton Khudobin by acting like he was going to take the puck through his legs, only to snap a backhander for his career-best 29th goal.

“I just thought I’d try that,” Giroux said, grinning.

Travis Konecny added a dazzling goal and an assist, Nolan Patrick also scored and Petr Mrazek made 36 saves for the Flyers. Philadelphia opened an eight-point lead over idle Florida, the last team that can overtake the Flyers for the final playoff spot in the Eastern Conference. The Flyers have three games left and the Panthers have five left.

Bergeron helped the ailing Bruins earn a point. With the goaltender pulled, Bergeron got his 30th goal on feed from Brad Marchand after the Flyers’ miscues.

“We didn’t have a ton of control, but we continued to stay on it,” Marchand said. “Tried to force them to make plays, turn a couple of pucks over, and it ended up in the net.”

Noel Acciari and David Pasrnak scored and Khudobin stopped 20 shots for the Bruins, who lost Brandon Carlo and Riley Nash to injuries a day earlier.

The Bruins welcomed Zdeno Chara back from an upper body injury a day after losing fellow defenseman Carlo to a possible serious leg injury, but they couldn’t complete a season sweep of Philadelphia.

“We got the point, but losing (stinks), Khudobin said.

Boston moved two points ahead of Tampa Bay atop the Eastern Conference. The Lightning host Boston on Tuesday.

A day after Vegas’ Willam Karlsson’s short-handed, between-the-legs goal was declared by many to be the NHL’s top goal this season, Konecny provided competition. His nifty stick work made it 2-0 just 25 seconds into the second period.

Konecny flicked the puck between two defenders along the boards, regained possession in the faceoff circle, went to his backhand to slip past a flailing Bergeron and then quickly switched back to his forehand and beat Khudobin from the slot for his 24th goal.

“I think it was just instinct. I reacted,” Konecny said. “When it happens, you’re just in the moment.”

But it was Giroux, who has a career-high 95 points, who came up with the final and most important tricky stick work.

“I’ve seen some great highlight-reel goals throughout the year,” Hakstol said, “but I don’t think I’ve seen a better one than that.”

NOTES: Joe McDonald of Boston Sports Journal reported that Carlo has been diagnosed with a broken left fibula, but the team doesn’t yet know if he’ll need surgery. If he avoids surgery, he could be out for 2 to 6 weeks. … Bruins defenseman Charlie McAvoy (knee) skated before the game and could return Tuesday.