John Tavares scored three goals for his second NHL hat trick, and Rick DiPietro made 40 saves to help the New York Islanders beat the Buffalo Sabres 5-3 on Saturday night and snap a three-game losing streak.

DiPietro played for the first time since he injured a groin during New York's five-game road trip.

Blake Comeau and Michael Grabner also scored for New York, 9-4-2 in its last 15 games.

Tomas Vanek, Tyler Ennis and Jochen Hecht scored for the Sabres, who got 32 saves from Ryan Miller.

The first period was scoreless, but featured several scoring chances. The best came with less than seven minutes remaining when Tavares ripped a shot that Miller snagged with his glove as he dived.

Buffalo started the second period with a two-man advantage, and grabbed a 1-0 lead 17 seconds in when Vanek tipped Tyler Ennis' shot past DiPietro.

The Islanders tied it when Tavares sent a wrist shot under the crossbar from in close at 7:50.

Tavares struck again at 10:34 on a power play when he backhanded Matt Moulson's attempt past Miller to give the Islanders a 2-1 lead. Tavares completed the natural hat trick when he put in a rebound at 13:36, scoring his team-leading 18th goal.

Comeau pushed the Islanders' lead to 4-1 with a shot off a rebound that got past Miller at 15:25. Comeau has scored in three straight games.

Ennis scored on a power-play rebound at 5:45 of the third period, cutting the deficit to 4-2. But Grabner put the Islanders back up by three goals with a short-handed goal at 16:52.

Miller was injured on the scoring play, but stayed in the game after being checked out by trainers.

Hecht finished the scoring with 1:45 left.

NOTES: The teams will play each other three times this month, twice on Long Island.