Boston’s Jake DeBrusk, bottom left, accidentally deflects the puck past goaltender Jeremy Swayman for a Rangers goal Thursday night at TD Garden. Artemi Panarin was credited with the goal – part of his hat trick in a 5-2 victory. Steven Senne/Associated Press

BOSTON — Artemi Panarin was credited with three goals – the second when Bruins forward Jake DeBrusk knocked the puck into the Boston net in the final minute of the second period – and the New York Rangers went on to a 5-2 win Thursday night at TD Garden.

The Rangers’ third victory over Boston in as many tries this season closed the Metropolitan Division leaders within one point of the defending Presidents’ Trophy winners for the best record in the NHL.

Adam Fox also scored and Jonathan Quick stopped 24 shots for New York, which has won six of its last eight games. Mika Zibanejad added an empty-netter with two minutes left, and Panarin got his career-high 41st goal a minute later with the Bruins’ net still empty.

DeBrusk and Justin Brazeau scored for Boston, and Jeremy Swayman made 26 saves. The Bruins, who have 97 points to New York’s 96, lost for just the second time in seven games.

The Bruins led 1-0 until Panarin scored through the legs of defender Pavel Zacha and Swayman with eight minutes to play in the second period. Panarin tallied his second when he tried to cross the puck to Alex Wennberg. DeBrusk dove onto the ice to block the passing lane but instead deflected the puck into the goal.

Brazeau tied it for Boston early in the third, cleaning up a puck that snuck behind Quick after a Brad Marchand shot. But just 40 seconds later, Fox wristed a bullet into the top shelf to give the Rangers a 3-2 lead.

Only subscribers are eligible to post comments. Please subscribe or login first for digital access. Here’s why.

Use the form below to reset your password. When you've submitted your account email, we will send an email with a reset code.