NEW YORK — Marian Gaborik scored twice in the first period and then completed his hat trick 27 seconds into overtime as the New York Rangers overcame a pair of blown leads and beat the Boston Bruins 4-3 on Wednesday night for their first win of the season.

Gaborik broke free and outraced Andrew Ference and Johnny Boychuk down the ice. His first shot was blocked by goalie Tuukka Rask, but Gaborik batted the rebound out of the air to end the game and start a cascade of flying hats onto the ice to celebrate his 14th NHL hat trick.

Taylor Pyatt also scored for the Rangers (1-2), who squandered leads of 2-0 and 3-2 en route to avenging a season-opening loss at Boston on Saturday. Henrik Lundqvist made 26 saves for the win.

Brad Marchand and Milan Lucic erased Boston's 2-0 deficit in the second period, and Nathan Horton got the Bruins even again at 3 with 4:23 left in regulation.

It was Horton's first goal in more than a year as he was sidelined by a concussion last January until the NHL resumed last weekend. The Bruins fell to 2-0-1 in their first road game of the season.

Gaborik scored his first three goals of the young season while playing on a new top line with star forwards Rick Nash and Brad Richards. Rangers coach John Tortorella said before the game that this trio makes the club's offensive attack unbalanced, but he could hardly quibble with the instant results.

After a poor first period, the Bruins controlled play early in the second and earned a power play 18 seconds in when Rangers defenseman Marc Staal was called for tripping. Marchand cashed in with his second goal of the season at 1:05.

Boston clamped down on defense, too, and turned an 11-4 shots disadvantage into a 13-11 lead before New York put its first puck in on Rask with 11:54 left in the second. That broke a stretch of 14 minutes, 14 seconds between Rangers shots.

Still, Boston kept the pressure on Lundqvist, and the Bruins got to him again after the Rangers left Lucic all alone in front of the crease. Defenseman Zdeno Chara found him there with a pass, and Lucic fired a hard forehand in on Lundqvist that was blocked. The rebound, however, came right back to Lucic, who smacked the puck in with a second swipe to tie it at 12:24.

Just when it seemed the game had turned completely in Boston's direction, Pyatt restored the Rangers' lead 46 seconds later when he put in a rebound of Derek Stepan's drive that bounced off Rask's chest.

New York nearly had a two-goal lead again, but Carl Hagelin's drive that beat Rask was wiped off because Mike Rupp had been called for roughing just before the shot.

The Rangers were lucky to escape the second with the lead, as the Bruins again swarmed around Lundqvist and fired away at him.

That was a far cry from the first period when New York appeared to be in total control. It took until their third game for the Rangers to post their best period of the young season and grab their first lead.

Gaborik nearly scored his first less than 5 minutes into the game when he jabbed at a loose puck after Rask let it go free by taking his glove off of it. Rask fell onto his back, with his arms outstretched inside the net like a snow angel, and the whistle blew. A video replay ensued, but the puck never crossed the goal line.

Just 26 seconds after being thwarted, Gaborik finished off a brilliant end-to-end passing play for his 325th NHL goal.

Defenseman Michael Del Zotto started the play with a pass from behind his net out to center ice, where Richards deftly tipped it forward to Nash in the Bruins zone. Nash sent a crisp cross-ice pass to Gaborik, who patiently carried the puck down to the goal line and skillfully flicked a parallel shot under the crossbar behind Rask, that popped the water bottle out of its holder on top of the net at 4:36.

Gaborik struck again 2:13 later, this time set up directly by the defense pair behind him.

Rask had allowed a total of two goals in two games over 125 minutes of action this season before New York's big first period. The Bruins were being outshot 8-2 at the time, prompting Boston coach Claude Julien to use his lone timeout.

The Bruins doubled their shot total from four to eight in the final 2:31 of the period, despite being short-handed for two minutes after Adam McQuaid earned an extra roughing penalty when he dropped the gloves to fight New York's Brian Boyle.

NOTES: RW Arron Asham, who made his Rangers debut Sunday vs. Pittsburgh, sat out because of a groin injury. He was replaced in the lineup by D Steve Eminger. Stu Bickel moved up from defense to fill Asham's forward spot in limited ice time. ... With his next win, Julien will move into a third-place tie with Don Cherry (231) on the Bruins' career coaching list. ... Lundqvist made his 26th straight start against the Bruins, dating to Jan. 13, 2007. ... The teams will meet one more time this season, at Boston on Feb. 12.