BOSTON — David Krejci thought there were a few seconds left before overtime.

He was surprised when he saw how close it was.

Krejci tipped in a shot with eight-tenths of a second left in the third period Thursday night to lift the Boston Bruins to a 2-1 victory against San Jose, sending the Sharks to their first regulation loss of the season.

“Actually I thought there might be more than 10 seconds, maybe 15, 20 seconds left,” he said, breaking into a smile. “Then we scored it and (Milan Lucic) said ‘Look up.’ I looked up and it was .8. It was even sweeter.”

Jarome Iginla scored his first goal with the Bruins (7-2) and Tuukka Rask was outstanding, making 38 saves.

“I was pretty excited to get my first in a Bruins uniform and to get it at home, get it in a tough game, and to get it unexpectedly,” Iginla said. “It’s kind of like you throw it at the net and ‘Wow.’ That was cool. It’s been a while. You always hope it’s coming.”

The Sharks dominated for most of the night until Krejci won it.

Patrick Marleau had San Jose’s goal, his eighth of the season. Antti Niemi stopped 15 shots.

Krejci, positioned in the slot, tipped defenseman Adam McQuaid’s shot from the point between Niemi’s pads for the winner.

“There was a guy in front so I thought just to watch the puck and I thought I had it, but he tipped it kind of back the same way where I was coming from,” Niemi said. “Yeah, tough way to lose with just a little bit left in the game.”

The Sharks (8-1-1) made it 1-1 on the opening shift of the third period when Marleau swooped in from the left wing, slipping a rebound past Rask 18 seconds into the period.

Seconds later, Rask came across the crease and made a blocker save on Tomas Hertl at the end of a two-on-one break. The Sharks kept up the pressure with a flurry of shots over the next two minutes.

“I looked up at the clock and was happy there was .8,” Boston Coach Claude Julien said.

The Bruins had an excellent chance with two minutes left when Niemi dropped to make a pad save on Krejci’s bid from in close.

Rask’s play kept Boston in this game.

“Their goalie played well tonight and made a lot of key saves for them,” Marleau said.

Iginla had given Boston a 1-0 lead with 1:12 left in the second when he collected the rebound of Dennis Seidenberg’s shot near the bottom of the right circle, firing a shot that trickled into the net.