The Bruins played with fire Wednesday night, and they got burned.

Boston blew a two-goal lead in the third period and lost to the New York Rangers 4-3 after falling in a shootout 2-1 at Madison Square Garden.

Danton Heinen, David Pastrnak and Patrice Bergeron provided the Bruins’ regulation goals. Mika Zibanejad, Kevin Hayes and Filip Chytil accounted for New York’s tallies. Zibanejad, Brad Marchand and Tony DeAngelo scored in the shootout.

Jaroslav Halak turned away 36 shots for the Bruins, while New York netminder Alexandar Georgiev made 27 saves.

The Bruins fall to 29-17-8 with the loss, while the Rangers climb to 23-22-8 with the win.

Here’s how it all went down:

With just over two minutes left in the first period, the Rangers provided the stanza’s lone goal.

Zibanejad dashed to the blue line to keep a loose puck in New York’s attacking zone, then backhanded it around the boards to the back of the net. Mats Zuccarello gained possession before finding Zibanejad camped out in the high slot and feeding him the puck. The center one-timed a rocket past Halak at 17:45 to open up the scoring.

Each team had a chance on the power play in the first, but neither could convert. After a minor scrum late in the period, Sean Kuraly (roughing) and Jimmy Vesey (cross-checking) both were handed penalties, so the period ended with 52 seconds of 4-on-4.

The Rangers ultimately outshot the B’s 12-9 in the period.

It hardly was a surprise the Bruins started the game off slow considering they were playing their third game in four nights, with the previous two contests featuring pretty heavy opponents. But in the second period, B’s head coach Bruce Cassidy did some line shuffling, putting Heinen on the first line, Pastrnak on the second and Jake DeBrusk on the third, and the move paid off.

At the 10:37 mark, the Bruins leveled the game at one. Boston won a face-off in its attacking zone, and Marchand slid a pass up to Matt Grzelcyk at the point. Grzelcyk unleashed a slap shot, and Heinen, who was just in front of the net, tipped it in.

The Bruins took the lead just 1:12 later, and it all began with Peter Cehlarik winning a puck battle, then finding Kevan Miller at the blue line. The defenseman hit David Krejci with a pass that slid diagonally across the zone. Krejci quickly threw the puck to the net and Pastrnak was there to redirect it home.

Boston extended its lead at 15:11 with DeAngelo in the penalty box for tripping. After a Pastrnak shot from the top of the circle was turned away by Georgiev, the puck found Marchand, who directed the puck to Torey Krug at the point. Krug fired a shot, and as the puck zipped to the net, Bergeron got a piece of it to up the Bruins’ lead to 3-1.

The Rangers didn’t lie down in the third period, pulling back within one goal before the midway point of the final stanza and tying it shortly thereafter.

A stretch pass from DeAngelo found Pavel Buchnevich, who was stuffed by Halak on the doorstep. Vesey got the rebound, spun and found Hayes crashing in, and Hayes finished with ease.

New York got a quality power play opportunity with just under eight minutes left when Charlie McAvoy was whistled for boarding, and the home side made sure to cash in.

Buchnevich slapped a shot from the point that hit off the inside of Halak’s left pad and bounced off the post. Chytil was right on the doorstep and poked it home on the wide-open net.

The five minutes of 3-on-3 were absolutely thrilling, but neither side could score the winner, sending the game to a shootout.

Zuccarello and Cehlarik couldn’t execute in the first round, nor could Kevin Shattenkirk and Pastrnak in the second. Zibanejad elevated the puck over Halak in the third round to put the Rangers on the board, but Marchand responded by sneaking a puck five-hole to tie up the shootout.

Hayes and McAvoy missed in the fourth round, then Chytil rung his shot off the post and DeBrusk put his attempt in Georgiev’s glove in the fifth round. Both Vesey and Heinen were unsuccessful in the sixth round.

In the seventh round, DeAngelo got his wrist shot over Halak’s glove to put the pressure on the Bruins, and Krejci was unable to answer.

The Bruins will have a few days off before returning to action Saturday afternoon against the Los Angeles Kings. Puck drop from TD Garden is set for 1 p.m. ET.

This Bruins Wrap is presented by Plainridge Park Casino.

Thumbnail photo via Adam Hunger/USA TODAY Sports Images