Jeff Carter scored, and Tristan Jarry made 28 saves for the Penguins (32-15-3), who had won four straight and fell one point behind the Washington Capitals, who defeated the Islanders 1-0 on Tuesday, for first in the division.
The Penguins and Capitals play a two-game set at Washington on Thursday and Saturday.
"I think when the stakes are high like this, both teams have a lot on the line," Pittsburgh coach Mike Sullivan said. "Boston, obviously, give them credit. They had a strong response game. They played hard. … I don't think we were at our best, but having said that, I thought we were competing. But we were right there."
Krejci gave the Bruins a 1-0 lead at 18:10 of the second period. He deked around Mike Matheson to the left circle, where he scored on a backhand to end Jarry's shutout streak at 125:36.
The goal was Krejci's seventh this season but fourth in the past six games.
"We addressed some things before the game," Krejci said. "Obviously, we know where we're at in the standings, what's going on around us. We talked about some stuff. For the most part, we stuck to the game plan and did exactly what we talked about."
Marchand made it 2-0 with his 26th goal of the season at 9:11 of the third period. His initial shot bounced high off Jarry and landed for David Pastrnak, who took a wrist shot that produced another rebound for Marchand at the right post.