Blake McLaughlin knew he had messed up. His errant pass in the second period led to a shorthanded goal that gave Bemidji State a lead over the Gophers on Saturday night in the second semifinal of the Mariucci Classic.

“I told [Sammy] Walker, ‘If I don’t score, I could be a in a heap of trouble,’ ’’ said McLaughlin, a sophomore forward from Grand Rapids.

McLaughlin isn’t in that heap of trouble because he intercepted a pass and scored with 2 minutes, 50 seconds left in the third period in a 5-2 victory over Bemidji State in front of 7,614 at 3M Arena at Mariucci.

His goal, which broke a 2-2 tie and proved to be the game-winner, plus late empty-net tallies by Scott Reedy and Walker in the final 1:17, sent the Gophers (6-9-4) into Sunday’s 7 p.m. championship game against St. Cloud State.

The Huskies were a surprising 7-2 winner over No. 2 Minnesota State Mankato earlier Saturday.

Bemidji State and Minnesota State Mankato will meet for third place at 4 p.m. Sunday.

Sunday’s final will mark the first time Gophers coach Bob Motzko faces St. Cloud State, the team he coached from 2005-18 before being hired by Minnesota.

Saturday’s victory was the 300th of Motzko’s career.

“It was bound to happen,’’ Motzko said of the matchup with the Huskies. “Holiday tournament. Championship game. Love it.’’

Wearing gold sweaters with “Wooger’’ on every player’s nameplate in honor of the former Minnesota coach who died on Dec. 14, the Gophers also got a goal from Reedy in the first period, and one from Garrett Wait in the second and 28 saves from goalie Jack LaFontaine.

Those contributions helped Minnesota overcome a stout defensive effort by Bemidji State (8-6-3), which held the Gophers to nine shots on goal through two periods and 18 for the game.

Bemidji State, with the best penalty kill in the nation (47-for-50) entering the game, snuffed out all three of the Gophers’ power plays and Owen Sillinger scored shorthanded early in the second period for a 2-1 Beavers lead.

The score was tied 1-1 after one period and 2-2 after two before the Gophers found a way to break through in the third.

“That’s college hockey right now,’’ Motzko said. “You’re going to go into third period tied, and it’s one goal.

“We’re at home, and we needed to take advantage of that.’’

That the Gophers did, with McLaughlin atoning and then passing a souvenir to Motzko — the puck from his 300th win.

“It was a real special moment,’’ McLaughlin said. “I’ve never given a coach a puck for a milestone win. It was really cool for us.’’