The Rangers took a 2-0 lead, fell behind 3-2, regained a 5-3 advantage and then found themselves tied after Michael Grabner and Blake Comeau scored for the Islanders less than 2 minutes apart in the third period.
Gaborik, however, tallied on a wrist shot 25 seconds after Comeau's goal to hand the Islanders their 15th loss in 16 games. The Islanders have won just five times all season, three fewer than any other team in the league.
It was the 12th career hat trick for Gaborik, who produced the Rangers' last three goals. He has eight for the season.
Marty Biron started in goal for the Rangers and gave up three scores on 21 shots before being replaced by Henrik Lundqvist.
Rick DiPietro took the loss, giving up all six goals on 26 shots. The teams will meet again Friday in Madison Square Garden.