BUFFALO, N.Y. — “That play,” David Pastrnak said after scoring his Game 5 overtime winner, “started long before.”

Pastrnak saved the Boston Bruins’ season with a forehand-backhand-forehand beauty on Alex Lyon at 9:14 of OT in his team’s 2-1 win. He almost never got the opportunity to score the winner. Just seconds before, he was on the bench, waiting for Casey Mittelstadt to finish his shift. Elias Lindholm and Morgan Geekie, Mittelstadt’s linemates, had already gotten off.

“This play goes all the way back to the last shift,” Pastrnak said. “Lindy, Geeks and Casey — I’m not sure who was there for D — it was a heck of a push by Buffalo. We defended really well. Got the puck out. (Jeremy Swayman) made some big saves. Got the puck out. Got the change. Next thing you know, we have the game the other way.”

By the time Mittelstadt got to the bench, he had been on for 1:21. The Sabres attempted seven shots on the Mittelstadt-Lindholm-Geekie line. Two of Alex Tuch’s shots were on net. The season could have ended during that stretch without Pastrnak on the ice.

As Lindholm, the first of the three forwards to change, approached the bench, Marat Khusnutdinov hopped over the boards with a purpose and saw Mattias Samuelsson send a pass to Peyton Krebs in the neutral zone.

Khusnutdinov knew his job: get above Krebs to disrupt his offensive-zone entry. If Khusnutdinov didn’t get there, Krebs had a lane to hit Ryan McLeod for a possible winning approach. McLeod had a step on Andrew Peeke, who had just changed for Henri Jokiharju.

“McLeod’s going to have a breakaway if we execute,” said Sabres coach Lindy Ruff. “That was their defenseman leaving the ice and he’s coming on after a change.”

Khusnutdinov arrived with enough speed to force Krebs to cough up the puck. Hampus Lindholm, who was going with Jack Quinn, was in the right spot to execute the recovery.

“That’s what I mean,” Lindholm said of Khusnutdinov’s arrival, “when I talk about us playing our way. We defend hard. Then it’s going to lead to offense the other way. Sometimes it can get frustrating playing that way because you never know when it’s going to come. But we won this hockey game. We did it in OT. So you never know. You just have to keep sticking with it.”

By then, Pastrnak had taken Mittelstadt’s spot. He saw the turnover. He anticipated that Lindholm would be first on the puck. So Pastrnak swung to the strong side, turned up the ice and waited for what he hoped was coming: a Lindholm TD pass.

“Marat did a great job hunting,” Pastrnak said. “Took a nice swing at the stick and it bounced to Hampus. In that moment, as soon as I saw Hampus had the puck on his stick, I turned my skating toward their net. I knew there was a chance.”

Even though he was two zones away, Lindholm knew what his teammate was going to do. They’ve linked up this way before.

“I’ve played with Pasta long enough to know he likes to sneak away for those,” Lindholm said. “I saw him kind of start coming with his little loop. He’s pretty special when it comes to those opportunities.”

Two years ago, Lindholm’s indirect pass in Game 7 against the Toronto Maple Leafs sprung Pastrnak for the overtime winner. This time, it was up to Pastrnak to stay onside. He has a knack for it.

“There’s only a few players that can do that,” said Bruins coach Marco Sturm. “What I mean by that, it’s not the finish, but the way he doesn’t go offside. That’s not the first time.”

An instant after Lindholm’s pass entered the offensive zone, Pastrnak grazed the blue line with the toe of his left skate. He settled the puck, shook off Samuelsson’s stick check and pulled Lyon out of his crease by going to his backhand. With Lyon down and out, Pastrnak jerked the puck back to his forehand for a slam-dunk winner.

Pastrnak has run hot and cold in Round 1. No. 88 had one goal and four assists through the first two games, then was shut out in the two following games at TD Garden.

But with the Bruins up against the wall, Pastrnak scored his team’s most important goal of the season. It is what he does.

“Somehow, he always gets it done,” said Sturm. “What a nice finish from him. I’m just very happy because this guy puts a lot of pressure on himself. He wants to be the difference. Today he was.”