Pacioretty scored in all three periods, and the Canadiens (22-24-9) moved one point ahead of the Islanders (22-23-8) in the tightly packed non-playoff section of the Eastern Conference.
Carey Price made 31 saves for his fifth win in seven games. The Islanders scored twice in the last three minutes of the third period, but couldn't get even.
Pacioretty scored his 20th goal of the season at 1:23 on a wrist shot from the top of the right faceoff circle, beating goalie Evgeni Nabokov, who was coming off a 45-save shutout of the Philadelphia Flyers on Tuesday. Erik Cole had the assist
Pacioretty, a first-round draft pick by the Canadiens in 2007, made it 2-0 at 9:30 of the second period. He completed his hat trick with an empty-net goal with 1 second left in the game.
Gomez, who hadn't scored in 24 games this season and since last Feb. 5 overall, tallied 9:50 into the third period with assists to defensemen Rafael Diaz and Chris Campoli.
Matt Moulson made it 3-1 with 2:41 remaining on a power play, with an assist from John Tavares, who earned the 100th helper of his NHL career.
Islanders captain and defenseman Mark Streit made it 3-2 just 48 seconds later, but the Islanders couldn't muster the tying goal after pulling Nabokov for an extra skater.
Price improved to 20-19-8 this season.
It was the first time that Montreal has won three straight games since a season-best, four-game spurt from Oct. 26-Nov. 4. The Canadiens had home wins earlier this week over Winnipeg and Pittsburgh.
The Islanders are 6-2-2 in their last 10 and 11-6-2 in the past 19. Nabokov had won seven of nine outings, allowing one goal or fewer in six of those decisions.
The game was the third of four meetings between the teams. The Islanders won 4-3 at home on Nov. 17, and the Canadiens earned a 5-3 victory on Dec. 13 in Montreal.
NOTES: The Canadiens are two wins away from 3,200 in franchise history. . The Islanders have scored 9,998 goals in their history, dating to 1972. . Last season, the Islanders were 15-12-6 after the All-Star break. They are 3-1-1 this season since the break.