BOSTON -- The Flyers' power play, last in the NHL, has been abysmal most of the season, but it awakened at an opportune time Thursday night at TD Garden.

As a result, the Flyers extended their winning streak to a season-high six games as they rallied past Boston, 3-2, in overtime.

The Flyers dominated the play after the first period, and defenseman Travis Sanheim scored the winner with 2 minutes, 4 seconds left in overtime. Sanheim, playing in his 100th career game, scored on a power-play wrist shot from the top of the left circle as Wayne Simmonds set a screen.

“Simmer did a great job screening in front, so I just tried to pick a corner,” Sanheim said of his four-on-three goal.

In their only other power play of the night, the Flyers' Oskar Lindblom scored the equalizer, knotting the score at 2-2 with 9:24 left in regulation as he tipped in Jake Voracek’s shot. Before that goal, the Flyers had been 2-for-25 on the power play in their last nine games.

“We’re looking for answers on the power play and just trying to get confidence and make the right plays," Sanheim said. “It hasn’t been going in for us, and it’s good to see two go in tonight.”

The Flyers faced a 2-1 deficit heading into the third. They had won just one of 24 games (1-20-3) when trailing after two periods, and they inched to within nine points of a playoff spot.

“I thought we worked really hard as a team," Scott Laughton said after the Flyers outshot the Bruins, 41-25, “and we got rewarded. After the second period, the message was to do the same things we were doing, and Oskar comes up with a big goal."

“We came out flat a little bit, but we stuck with the game plan and the guys battled tonight,” said captain Claude Giroux, who tied the game at 1-1 by scoring on a breakaway with 43.2 seconds left in a Boston-dominated first period. “These kind of wins feel a little better.”

The loss prevented Tuukka Rask from becoming the winningest goalie in Boston’s history. He is tied with Cecil “Tiny” Thompson (252 wins).

The Flyers got a pair of assists from Jake Voracek, a stellar game from Ivan Provorov -- he played a career-high 30:20 -- and 23 saves from Carter Hart, who won his fifth straight.

“We’re feeling confident, and the boys played really good,” Hart said. “We played some of the best hockey I’ve seen them play.”

Boston right winger David Pastrnak is making a lot of scouting directors and general managers sorry they allowed him to slip to 25th overall in the 2014 NHL draft in Philadelphia.

Pastrnak, 22, who was selected eight picks after the Flyers took Sanheim, scored twice Thursday and reached the 30-goal mark for the third straight season.

But it wasn’t enough.

Rask, who returned from a concussion suffered Jan. 19, made 38 saves.

Rask stopped Laughton’s penalty shot with 13:18 left in regulation to preserve Boston’s 2-1 lead. Laughton had been pulled down on a breakaway by John Moore.

After Lindblom’s tying goal, the Flyers capitalized on Brad Marchand’s penalty in overtime.

Earlier, Giroux tied the score at 1-1 after taking a slick feed from Voracek late in the first.

“We weren’t playing our best hockey in that period,” Giroux said. “I think we were sitting back a little too much, but being able to tie it up was huge for us.”

“That,” Hart said, “gave our group a lot of life.”

The Flyers gained momentum from the goal and pressured the Bruins early in the second, but Rask made a handful of saves, including a point-blank stop on Lindblom.

Boston regained the lead, at 2-1, on a deft tip-in by Pastrnak, who deflected the puck past Hart despite having defenseman Robert Hagg in his face with 14:49 to go in the second.

The Flyers will next have to deal with one of the NHL’s other top scorers, Connor McDavid, when they host Edmonton on Saturday afternoon and start a five-game homestand.

Hart, who grew up near Edmonton, hopes to get the start.

“It would just be cool to play Edmonton. That’s my hometown team,” he said with a smile.

Hart became the 10th goalie in league history to register a five-game winning streak before his 21st birthday, according to the NHL.