BOSTON -- Morgan Geekie scored his first NHL hat trick for the Boston Bruins in a 5-4 win against the Vegas Golden Knights at TD Garden on Thursday.

“It’s something that you don’t ever really think about coming into a game, but it’s always fun,” Geekie said after his 235th NHL game. “Especially when you get two points, for sure. So it was good to close that one out, especially the way we finished the last couple games.”

Mason Lohrei scored the go-ahead goal, David Pastrnak and Kevin Shattenkirk each had two assists, and Jeremy Swayman made 32 saves for Boston (35-12-14), which ended a three-game losing streak and extended its point streak to seven games (3-0-4).

“I remember at the beginning of the year, [Bruins coach Jim Montgomery said] how every 10 games, the League gets harder, and that’s the truth,” Lohrei said. “Definitely deeper into the season here, games seem like they mean a lot more, so going out there and executing and getting wins is awesome.”

Chandler Stephenson had a goal and an assist, and Adin Hill made 27 saves for Vegas (33-20-7), which has lost six of its past eight (2-5-1).

“I think it’s pretty common for a team, when they get ahead, the other team’s going to have a push,” Golden Knights coach Bruce Cassidy said. “No matter whose building you’re in, when it’s two good teams, so our guys got a lot of pride, and it showed. We got better and got ourselves back in the game.”

The Bruins led 3-0 after the first period and 4-3 entering the third before Vegas tied it. Across its previous six games, Boston squandered a third-period lead to go past regulation in four of them and wound up losing three.

Lohrei gave the Bruins a 5-4 lead on the power play at 15:23 of the third period with a one-timer from the right circle.

“To be able to overcome, again, giving up a lead, but to come through,” Montgomery said. “And I thought in the third period, we carried the play for the majority of it. So it’s nice to be able to see the second power-play unit to come through in a big way.”

VGK@BOS: Lohrei lights the lamp with go-ahead PPG

Geekie put Boston ahead 1-0 at 14:34 of the first period, finishing off Trent Frederic’s stretch pass on a breakaway.

Jesper Boqvist made it 2-0 30 seconds later at 15:04 after Jakub Lauko hit him in the slot with a backhand pass from the goal line.

Geekie pushed it to 3-0 at 16:54 with a one-timer off Pastrnak’s cross-ice feed.

“Stanley Cup champs last year, so you want to have a solid game against those guys,” Bruins forward Charlie Coyle said. “And in the end, you want two points. It wasn’t pretty, wasn’t easy, but in the end we got two points.”

Paul Cotter cut it to 3-1 at 1:48 of the second period, batting the puck in out of the air in the left circle.

Alex Pietrangelo made it 3-2 at 6:57, scoring on his third rebound attempt after Swayman stopped the first two in front.

“When we go on the forecheck, we retrieve pucks,” Golden Knights forward Nicolas Roy said. “We’re hard to play against, five-man units. I think that’s what we did really well in the second half of the game, and go to the net, put pressure on them, and I think that’s what we [need] to build on.”

VGK@BOS: Cotter swings and sends it home

Geekie completed his hat trick to make it 4-2 at 16:32, tipping in Pastrnak’s shot at the doorstep.

Michael Amadio cut it to 4-3 at 17:46 when he scored from the slot after Vegas’ forechecking forced a turnover, and Stephenson tied it 4-4 at 5:01 of the third on a short-handed breakaway.

“It’s always tough in here,” Stephenson said. “[The Bruins] are one of the better home teams coming in (now 19-7-5), so yeah, you expect that out of them. Just caught us on our heels and we battled back and missed a couple plays, and here and there, but again it’s our start.”

NOTES: Vegas forward Jonathan Marchessault had an assist to extend his point streak to four games (eight points; four goals, four assists). He also became the first player to reach 400 points with the Golden Knights (182 goals, 218 assists in 492 games). … Pietrangelo’s goal was his 600th NHL point, making him the ninth active defenseman to reach that milestone (144 goals, 456 assists). … The Bruins’ streak of six straight overtime or shootout games ended. … Boqvist has seven points (three goals, four assists) in the past seven games.