The teams battled to a 2-2 tie through two periods, but Montreal dominated the closing 20 minutes. The Islanders had won their last three meetings with the Canadiens.
Subban had two goals for the Canadiens, running his total for the year to eight.
Brian Ginota put Montreal in front 48 seconds into the third period before the two quick goals from Subban and Gallagher gave the Canadiens some breathing room.
Montreal won for the 20th time this year and is 14-1-4 over its last 19 outings.
Carey Price had 25 saves in the victory. The loss went to Kevin Poulin, who allowed all five goals on 29 shots.