The Islanders went up against a rookie goaltender in their season opener, but just could not Capital-ize.

Ilya Samsonov stopped 25 shots, T.J. Oshie scored the tiebreaking goal and the Capitals beat the Islanders 2-1 on Friday night at Nassau Coliseum.

“I thought we’d be a little bit rusty not having played already,” Islanders coach Barry Trotz said. “I didn’t mind our first [period]. … The second period I thought we played a little bit better, certainly got a little bit of momentum. They scored a power-play goal and in the third they were the better team.”

Devon Toews scored for the Islanders and Semyon Varlamov, making his Islanders debut, made 26 saves.

Both teams had chances in this matchup of the Metropolitan Division’s top teams from last season. The Capitals finished first, but were beaten by Carolina in seven games in the first round of the playoffs. The Islanders, who finished a point behind, swept Pittsburgh in the first round before being swept by the Hurricanes.

“First win in the NHL, I feel wonderful,” the 22-year-old Samsonov said, before getting a shaving-cream pie to the face from teammate Tom Wilson. “Everybody helped me, played a good game.”

Capitals coach Todd Rierden was also pleased with the debut of his young goalie, the 22nd overall pick in 2015 who played for Hershey of the AHL last season.

“I thought he played great,” Rierden said. “He looked very comfortable. I thought it was a great first game for a highly touted prospect.”

Jakub Vrana got his second goal in two games for the Capitals, who opened the season with a 3-2, overtime win at St. Louis on Wednesday night.

Lars Eller nearly extended Washington’s lead to two goals but his shot went off the crossbar 5:40 into the third period, and Mathew Barzal’s attempt to tie it hit a goalpost nearly two minutes later.

The Islanders pulled Varlamov for an extra skater with about a minute left, but couldn’t get the tying goal.