San Jose Sharks center Joe Thornton (19), left, looks down as the Boston Bruins celebrate their 2-1 win Thursday in Boston after scoring the final second of the game.

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

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

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 game-winner.

The Sharks (8-1-1) tied the game at 1-all 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 2-on-1 break. The Sharks kept up the pressure with a flurry of shots over the next 2½ minutes.

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

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 after hitting Niemi’s right pad and slipping between his legs.

Signed to a one-year free-agent deal that could earn him as much as $6 million with incentives, Iginla had a big smile on his face as he went over to the bench to accept congratulations from his teammates.

The 36-year old winger vetoed a trade that would have sent him to the Bruins when they had a deal in place at last season’s trading deadline. He ended up accepting a deal to Pittsburgh, which was swept in the Eastern Conference finals by Boston last spring.

Niemi had robbed Patrice Bergeron about 2 minutes before Iginla’s goal when he came across the crease to make a glove stop at the end of a 2-on-1 break.

Bruins winger Shawn Thornton unloaded a slap shot that caromed off the left post 3 minutes into the second.

The Bruins played the first period like many of their fans from the slimmed-down crowd — like they had something else on their minds. With the Red Sox hosting Game 2 of the World Series at Fenway Park about 3 miles away, there were a decent number of empty seats despite the club’s 170th straight sellout of TD Garden.

The arena, which was less than a third full about 10 minutes before game time, ended up being only about three-quarters filled, with many open seats in the club and lower sections.

San Jose outshot Boston 16-3 in the opening period — at times, controlling the puck for lengthy stretches in the Bruins’ zone.

NOTES: Boston’s GM Peter Chiarelli said in a statement before the game that winger Loui Eriksson was “diagnosed with a concussion and will be out indefinitely” after a hit on Wednesday from Buffalo’s enforcer John Scott, who was issued a match penalty for charging. Scott was suspended indefinitely by the NHL on Thursday. It ended Eriksson’s streak of consecutive games played at 148. ... It was the Sharks’ second game of a season-long five-game road trip. They also play at Montreal, Ottawa and the Los Angeles Kings before returning home to face Phoenix on Nov. 2. ... Boston defenseman Dougie Hamilton faced his brother, Freddie, a center with the Sharks.