SAN JOSE — One of these days, the Sharks are going to lose a hockey game.

They came close Tuesday night, but a late third-period goal by Logan Couture and a strong performance by goalie Antti Niemi in the shootout gave San Jose a 3-2 victory over the Anaheim Ducks in a game where the Sharks clearly were off their game.

“We’ve got to be excited that we put points in the bank and were able to come back,” Sharks coach Todd McLellan said after his team improved its franchise-best start to 6-0. “But we have to tell it like it was — they were the better team.”

While Niemi was stopping Ducks forwards Bobby Ryan, Corey Perry and Teemu Selanne, who hit a crossbar, in the shootout, the Sharks got a goal from Michal Handzus before Anaheim goalie Jonas Hiller stopped Joe Pavelski and Ryane Clowe.

“He’s known for scoring and we played the odds,” McLellan said of the decision to use Handzus, who is something of a shootout specialist but still looking for his first point this season.

The Sharks were trailing 2-1 with less than three minutes to play in the game when Scott Gomez earned his first point as a Shark by dropping a pass to Couture, who fired a 47-foot wrist shot that eluded Hiller at 17:15.

“He knew I was coming late — he’s a playmaker and he made a play,” Couture said of Gomez. “I just threw it at the net. We didn’t shoot the puck enough on net tonight and I wanted to get the puck there and I was able to find a hole.”

Pavelski had given the Sharks a 1-0 lead in the first period, but the Ducks got goals from Francois Beauchemin and Matt Beleskey less than a minute apart in the second period to take a 2-1 lead that lasted until Couture evened things up.

San Jose was without defenseman Dan Boyle, who had missed the morning skate with what McLellan said was a cold not expected to sideline him that night.

Without Boyle, the Sharks seemed to have trouble establishing an offensive presence as they were outshot 30-18 for the game.

“The first two periods, we weren’t very good,” Couture said. “Didn’t play enough in their end. Didn’t break out. The list goes on. It was an ugly win but we’ll take it this season, for sure.”

Despite the slow start, the Sharks did take a 1-0 lead at 9:46 of the first period after a 2-on-1 break that saw Joe Thornton pass the puck around Ducks defenseman Luca Sbisa to Pavelski, who beat Hiller on the stick side from the slot.

But two goals 59 seconds apart in the second period put the Sharks behind for the fist time in the past three games.

The crowd was already in a foul mood because no penalty was called against the Ducks when Couture appeared to be thrown off balance by Sheldon Souray while skating on a short-handed breakaway.

“Souray was grabbing me both sides, dropped his stick or maybe threw it. I couldn’t tell,” Couture said. “And I still had him beat. It just slid off the toe of my stick. But there’s non-calls in the game.”

Seconds later, Beauchemin fired a shot deep along the side boards and it bounced off Niemi into his own net at 8:40. Shortly after that, Ducks forward Ryan Getzlaf found Beleskey all alone in the slot and his one-timer made it 2-0.

Both teams had chances to win the game in overtime, with Hiller coming up big on a shot by Patrick Marleau, who was held without a goal for the first time all season, and Niemi robbing Perry.

Rookie Nick Petrecki, one of two Sharks’ first-round picks as the 28th player selected in the 2007 draft, made his NHL debut as Boyle’s replacement and was paired with Douglas Murray.

Anaheim forward Emerson Etem also skated in his first NHL game after being called up from Norfolk of the AHL. A Californian who grew up in Long Beach, Etem was the 29th player taken overall in the 2010 draft.

Clowe wasn’t contrite when it came to his stick-slamming outburst that helped earn him 37 minutes in penalties and an early exit in the Sharks’ 4-1 victory over the Vancouver Canucks on Sunday. “There’s no secret how I play. I’m an intense guy and I’m an emotional guy. I try to play on the edge and sometimes you go over. I don’t make any apologies for that,” Clowe said after Tuesday’s morning skate.

McLellan and Ducks coach Bruce Boudreau were roommates as minor league players in Springfield, Mass., in the 1980s. As things worked out, Boudreau holds the record of 200 NHL coaching wins in the shortest time (326 games) with McLellan right behind after earning his 200th Sunday night in his 333rd game.

One aspect of San Jose’s game that was consistently good against Anaheim was the penalty kill, which went 4 for 4 and has now climbed to 12th in the NHL with an 81.2 percent success rate.

Otto Warmbier was arrested in January 2016 at the end of a brief tourist visit to North Korea. He had been medically evacuated and was being treated at the University of Cincinnati Medical Center when he died at age 22.