Bob Gainey scored on a 60-foot drive late in the second period to break a 1-1 tie in Montreal last night and help the Canadiens end a New York hex with a 3-1 triumph over the Islanders, stopping the Stanley Cup champions' 13-game undefeated streak.

It was the first loss suffered by the Islanders since Feb. 25 and their first defeat away from home after eight straight victories on the road. It also was the first loss for rookie goalie Roland Melanson, who entered the game 7-0-1. The Canadiens had not beaten the New York club since Dec. 10, 1978.

Gainey picked up a pass from Rod Langway at the Islanders' blueline and lifted a high shot that eluded Melanson to break a 1-1 tie at 16:25 of the second period.

The Islanders took a 1-0 lead at 12:19 of the first period as Wayne Merrick drilled the puck past Montreal goalie Richard Sevigny just after a faceoff.

The Canadiens, who had suffered two losses in succession, tied the score with 40 seconds left in the opening period. Mark Napier got his 33rd goal on a power play when he slipped a rebound past Melanson.

Guy Lafleur, playing is his first game after missing six straight because of a charley horse and lacerations sustained in a car accident, assisted on two goals.