Johnny Boychuk scored with 5:35 remaining to put the Bruins ahead, 3-2, and Milan Lucic (two goals) added an insurance goal, finishing an odd-man rush from the left circle.
Boston dominated the final period, outshooting the Flyers, 22-8.
"We didn't come out and initiate anything in the third, and we were in our end the whole period," said coach Craig Berube, whose team would face Boston in the first playoff round if it fell to the second wild-card spot. "We were on our heels; we didn't get off walls quick enough to protect our net, and we let people get to the net on us.
"We made it too easy for them."
Boychuk scored what turned out to be the game-winner on a point drive after Patrice Bergeron won a clean draw from Vinny Lecavalier. Reilly Smith screened Ray Emery (37 saves) on the play.
Emery, who had a 1.60 goals-against average and .947 save percentage in his previous three starts, played a strong game and robbed David Krejci out front with a little over eight minutes left. A few minutes later, the Bruins put the game away.
A most unlikely player - Rosehill - knotted the game at 2 with 3:39 left in the second period.
Rosehill, known for his fists, used a spin move to get around defenseman Torey Krug in front and then beat Tuukka Rask (24 saves) to the far side. It was the fifth career goal for Rosehill, who won a fight with Shawn Thornton in the first period.
"This team has been playing a lot of good hockey since the Olympic break, and I haven't been a part of a lot of it, so it's my job to stay ready, and luckily I got in today and was able to help out a little bit," Rosehill said. "But we couldn't get the win, so it's disappointing on the whole."
Earlier in the period, Wayne Simmonds used a backhander to score on a rebound, tying the game at 1 and ending the Flyers' long scoreless streak. Simmonds, joy-struck, waved his arm in a circular motion and pounded the glass as the Flyers also snapped their 0-for-14 power-play drought.
But just 19 seconds after Simmonds' goal, Lucic scored from the high slot to put Boston ahead, 2-1.
Less than a minute later, Emery stopped Carl Soderberg on a breakaway, keeping the Flyers within a goal and setting the stage for Rosehill's game-tying goal.
Rosehill, who replaced Tye McGinn in the lineup, had been a healthy scratch in the previous 12 games, and the goal was his first since Nov. 9 against Edmonton. He has two goals this season on 10 shots.
Emery made two terrific stops - turning aside Loui Eriksson (four assists) and a rebound - but he had no chance when Krejci knocked in the second rebound of the flurry, putting Boston ahead, 1-0, with 4:04 to go in the first. It was Krejci's first goal in 17 games.
Breakaways. Lecavalier, who had been centering the fourth line recently, went back to left wing on the second unit. . . . Zac Rinaldo was promoted to the third line, and the fourth line had Adam Hall centering Rosehill and Michael Raffl. . . . Claude Giroux snapped a three-game pointless streak.