BOSTON — Jeremy Swayman rebounded from a rough stretch with 23 saves and the Boston Bruins clinched a playoff spot by holding off the Pittsburgh Penguins 2-1 on Saturday to halt a season-high three-game losing streak.

Trent Frederic and Erik Haula scored first-period goals for Boston, which went on the skid after winning 17 of 21.

Former Bruin Danton Heinen scored for the Penguins, who fell to 2-5-1 in their past eight games. Casey DeSmith stopped 27 shots.

The Bruins went 0-for-2 on the power play, extending their scoreless stretch to 25 straight.

The Penguins, who clinched a postseason berth earlier in the week for the 16th straight season, the longest active streak among North American pro sports teams, are not at their peak headed into the campaign’s final two weeks, and their Eastern Conference playoff seeding hangs in the balance.

A first-round matchup vs. the New York Rangers that seemed quite likely for weeks is on shaky ground. At 3-6-1 in their last 10 games, Pittsburgh (97 points) is now just five points ahead of the Washington Capitals (92), and the latter has three games in hand on the Penguins. Should Washington catch the Penguins, it’s possible Pittsburgh falls into the second wild-card slot in the East, which would mean a date against the likely top-seeded Florida Panthers.

Meanwhile, the Bruins, who played without leading goal scorer David Pastrnak for a sixth consecutive game because of an undisclosed injury, stemmed the tide on their recent woes and secured a postseason berth that, at times early in the season, didn’t seem so assured.

“We have a standard here, right? So we’re not going to go out and celebrate that we made the playoffs,” Boston coach Bruce Cassidy said. “But it’s still an accomplishment you should be proud of.”

The 23-year-old Swayman, who seemed to be a lock to be the No. 1 goalie for the playoffs about a month ago, lost his previous three decisions when he allowed a few soft goals. He made a handful of solid stops when the Penguins had two power plays in the second period and was steady with nine stops in the third.

“It’s really an important win for us, especially as of late,” Swayman said. “Just the fashion that we did it, making the small plays, simple plays, everything was crisp and on point for us. Just super excited, clinching the playoffs, and to do it at home is a cherry on top.”

Looking eager to erase their recent sporadic play, the Bruins grabbed a 2-0 edge just over two minutes into the game.

“There are still some things we need to clean up,” Cassidy said. “Some decision-making. We know we have to be better.”

Frederic backhanded in a rebound from the edge of the crease in the opening minute. Haula then fired a shot from the right circle that ricocheted into the net off Penguins defenseman Marcus Pettersson at 2:01.

Heinen fired a rising wrister over Swayman’s left shoulder 5:38 into the second.

Having clinched a playoff spot in their previous game Thursday night with a victory over the Islanders, the Penguins had a slow start. They steadied their play after being outshot 11-6 in the first.

The Bruins also played without defenseman Hampus Lindholm, who was out for his fifth straight because of an upper-body injury. Boston has major plans for Lindholm, acquired at the trade deadline, in the postseason, so that remains a situation to monitor.

But for now, the postseason berth is secured, and Boston can get to work on seeding and potential matchups.

“It’s not easy to do, year in and year out, in this league,” Cassidy said of clinching. “It’s not an automatic.”

The Associated Press contributed to this report.