''A little bit of an ugly third period for us, but we found a way at the end,'' Lee said. ''Right now, the two points is the biggest thing.''
Robin Lehner stopped 21 shots before leaving with an injury late in the third period. Thomas Greiss came on, stopped both shots he faced through overtime and denied Thomas Chabot and Bobby Ryan in the shootout.
The Islanders pulled into a tie with Washington atop the Metropolitan Division with identical 38-21-7 records and 34 regulation/overtime wins.
Trotz became the fourth coach in NHL history to reach the 800-win mark, joining Scotty Bowman (1,244), Joel Quenneville (890) and Ken Hitchcock (842).
With the Islanders coming in with three losses in four games on their season-high five-game homestand, and several players dealing with injuries and illness, Trotz said the milestone ''was least on my mind today.''
Lee, however, was glad to get his coach the win.
''It's really nice,'' he said. ''He's had a heck of a career. Happy to close this one out and move on.''
Oscar Lindberg, Ryan, Zack Smith and Jean-Gabriel Pageau scored for the Senators, who went to their first shootout this season and lost for the ninth time in 11 games. Craig Anderson finished with 34 saves.
''They're not at the top of the standings by accident,'' Ottawa interim coach Marc Crawford said. ''(We) faltered a bit in the second. ... (In the third) we got rewarded by going hard to the net.''
The teams meet again Thursday night at Ottawa to finish the home-and-home set.
''We got to clean up some stuff in our game, there's no question,'' Trotz said. ''We'll go over it tomorrow and we'll see if we're healthier and see what we'll do in terms of lineups.''
The Senators had the only shot on goal in the 3-on-3 overtime.
Ryan pulled the Senators to 4-3 as he deflected Christian Wolanin's shot past Lehner for his 14th at 7:38 of the third.
The Senators tied the score with 4:40 left as Brady Tkachuk plowed into Lehner and knocked the puck into the net. The goal was initially waved off, but the call was overturned after a video review determined Nelson pushed Tkachuk into the goalie.
Lehner was injured on the play and replaced by Greiss.
Trotz didn't have an update on Lehner's status after the game, saying, ''We'll see where he is in the morning.''
After a fast-paced first period that saw the Islanders take a 1-0 lead, the teams combined for five goals in the second - all in the first 10:02 of the period.
Gibbons tied the score 26 seconds into the middle period as he deflected Chabot's slap shot past Lehner's glove side for his fourth.
Toews put the Islanders back ahead at 2:34, beating Anderson on the blocker side for his fifth.
Lee pushed New York's lead to 3-1 as he deflected Nick Leddy's slap shot from the left point past Anderson's glove side for his 23rd at 5:45. It was also Lee's fifth goal in nine games.
Lindberg, acquired from Vegas in the deal that sent Mark Stone to the Golden Knights at the trade deadline, pulled Ottawa within one again 47 seconds later with his sixth of the season, and second in five games with the Senators.
Johnston restored New York's two-goal lead just past the midpoint of the period on the rebound of a shot by Leo Komarov. Johnston lifted the puck over the diving goalie, and it hit Johnston in the air and went in for his first of the season.
''It's awesome to see Ross score that goal,'' Lee said. ''In a tough situation, (he) comes in and scores a big goal for us.''
The Islanders outshot the Senators 26-8 in the second.
New York took a lead in the first period after the Senators turned the puck over in their defensive zone. Josh Bailey's one-timer off a pass from Nelson was stopped by Anderson. However, the puck bounded in front and Nelson backhanded it in for his 21st at 5:22.
NOTES: Smith played in his 600th regular-season game, becoming the ninth player in franchise history to accomplish the feat. ... The Islanders won the teams' first meeting this season, 6-3 at Brooklyn's Barclays Center on Dec. 28. ... With an illness going around the Islanders, F Michael Dal Colle and F Josh Ho-Sang were emergency recalled from Bridgeport of the AHL. Dal Colle played while Ho-Sang was scratched. ... Bailey's assist on Nelson's goal gave him 12 points (nine assists) in his last 13 games. ...New York went 0 for 3 on the power play and is 0 for 13 over its last six games.
Senators: Host the Islanders on Thursday night.
Islanders: At Ottawa on Thursday night before returning for a three-game homestand.
Follow Vin Cherwoo at www.twitter.com/VinCherwooAP
More AP NHL: www.apnews.com/NHL and www.twitter.com/AP-Sports
Copyright 2019 by AP. Any commercial use or distribution without the express written consent of AP is strictly prohibited.