UNIONDALE, N.Y. -- Barry Trotz became the fourth coach in NHL history to win 800 games, and the New York Islanders defeated the Ottawa Senators 5-4 in a shootout at Nassau Coliseum on Tuesday.

Brock Nelson, Devon Toews, Anders Lee and Ross Johnston scored for New York (38-21-7), which moved into a tie with the Washington Capitals for first place in the Metropolitan Division and avoided a three-game losing streak.

Robin Lehner made 21 saves but left the game with 4:40 remaining in the third period after a collision with Brady Tkachuk. Thomas Greiss made three saves in relief.

[WATCH: All Senators vs. Islanders highlights]

Trotz joins Scotty Bowman (1,244), Joel Quenneville (890) and Ken Hitchcock (843) as the only coaches with 800 NHL wins.

"Least on my mind today, trust me," said Trotz, who didn't have an update on Lehner's condition and was scrambling for a lineup with a flu bug going through the Islanders dressing room.

Brian Gibbons, Oscar Lindberg, Zack Smith and Jean-Gabriel Pageau scored, and Craig Anderson made 34 saves for Ottawa (23-38-6), which has lost eight of its past nine games.

"I thought it was a really good game against a really good team," Senators coach Marc Crawford said. "They're not at the top of the standings by accident; they play the game the right way. The way that they support the puck really taught us some lessons."

Video: OTT@NYI: Nelson pots juicy rebound for opening goal

Pageau tied it for the Senators at 15:20 of the third period when he poked the puck over the goal line after Tkachuk collided with Lehner. The goal was awarded on the ice, then was ruled no-goal, but Ottawa challenged and the goal was awarded following a video review to make it 4-4.

Lehner left the game after the play.

"Obviously, you don't want to lose him," Nelson said. "Hopefully he's all right and he's able to kind of clear through all the protocols and be back for us."

Nelson gave the Islanders a 1-0 lead at 8:22 of the first period on a rebound after Anderson made an initial save on Josh Bailey's one-timer from the right circle.

Gibbons tied it 26 seconds into the second period when he redirected Thomas Chabot's shot from the point to make it 1-1.

Video: OTT@NYI: Gibbons redirects home Chabot's shot

Toews quickly responded for the Islanders on a 2-on-1 with Michael Dal Colle to give New York a 2-1 lead at 2:34.

Lee made it 3-1 at 5:45 when he redirected Nick Leddy's shot from the left point eight seconds after an interference penalty against Senators defenseman Mark Borowiecki expired.

Ottawa got back within one at 6:32 when Lindberg poked Mikkel Boedker's rebound over the goal line to make it 3-2.

But Johnston powered his way to the net and knocked Leo Komarov's rebound past Anderson to give the Islanders a 4-2 lead at 10:02 for his first goal since Feb. 19, 2018.

Video: OTT@NYI: Johnston scores his first goal of the season

New York outshot Ottawa 26-8 in the second period.

Smith made it 4-3 at 7:38 of the third.

"We can't have third periods like that, especially with a two-goal lead," Islanders captain Anders Lee said. "But with the way things have been going, we found a way to get two points.

"It was ugly, it was a shootout. But it's fine."

Jordan Eberle and Mathew Barzal scored in the first two rounds of the shootout for New York. Greiss made the save against Chabot and Bobby Ryan shot wide.

They said it

"We got rewarded by going hard to the net in the third period, by demonstrating the support and the togetherness that you need to be successful. We really did like that third period; it was probably one of our better third periods of the entire year. To do it against a good club is … I don't want to use the word rewarding, but it at least shows the guys that they can do this against anybody if they put their minds to it, and that's what they did tonight. They were the guys that put their minds to it." -- Senators coach Marc Crawford

"It's awesome, it's a testament to his career and how long he's been in the NHL and how well he's done. It says a lot about what kind of person he is and the people around him. Happy to get that off our backs; I think he was sitting [on 799] for a little bit of time now. Good to get it for him." -- Islanders captain Anders Lee on coach Barry Trotz's 800th NHL win

Need to know

It was the first of a home-and home series, with the conclusion in Ottawa on Thursday. … Smith played his 600th NHL game. … The Islanders were without forwards Matt Martin and Cal Clutterbuck because of upper-body injuries. Dal Colle and forward Joshua Ho-Sang were recalled from Bridgeport of the American Hockey League on an emergency basis. Ho-Sang was a healthy scratch. … New York is 32-2-2 when it scores at least three goals.

What's next

Senators: Host the Islanders on Thursday (7:30 p.m. ET; TSN5, RDS, MSG+, NHL.TV)

Islanders: At the Senators on Thursday (7:30 p.m. ET; TSN5, RDS, MSG+, NHL.TV)

Video: Trotz secures 800th win as Isles top Sens in shootout