On the game-winning play, Desharnais got control of the puck to the left of the net. He skated behind the cage, circled to the front and slid a pass to a wide-open Pacioretty.
The Habs' left wing got a stick on it and popped it past New York's Evgeni Nabokov for the game's only goal.
Carey Price finished with a 21-save shutout as Montreal ended a two-game losing streak.
Nabokov also played well in his return from an 11-game injury absence, stopping 24-of-25 shots as the Islanders fell for the 12th time in 13 games.