BOSTON (AP) Boston's power play finally came through with two early goals Tuesday night.
The other side of the Bruins' special teams unit delivered in the end.
Gregory Campbell netted the game-winner with less than 10 minutes remaining and the Bruins fended off a late four-minute San Jose power play to earn a wild 5-3 win over the Sharks.
''Our special teams tonight were really good for us and we really needed that against that team,'' said Boston coach Claude Julien.
After twice squandering one-goal leads and overcoming a late deficit, the Bruins took the lead for good when Campbell tipped a pass from Daniel Paille through the legs of San Jose goaltender Antti Niemi with 9:18 left to play.
But Patrice Bergeron drew a double-minor penalty with 4:09 remaining, leaving the Bruins short handed against one of the best power play units on the road this season.
San Jose had converted on five of 15 chances entering the game, and added another one in the first period Tuesday.
''Bergy kills enough penalties for us,'' Campbell said, ''so it's important for us to do that for him.''
Goaltender Tuukka Rask and Boston staved off the Sharks' attack before David Krejci added an empty-netter with 24.5 seconds to go to seal the Bruins' third win in four games.
''It's pretty huge from our group, especially when one of your best penalty killers is in the box for the last four minutes,'' Julien said. ''I thought our guys the last four minutes did an unbelievable job of battling through.''
Boston got contributions from nearly half of its roster, as nine different players recorded at least one point.
Brad Marchand and Torey Krug scored power-play goals, Seth Griffith netted his first career NHL goal and Milan Lucic had three assists. Rask made 31 saves.
''You've got to have everybody going because that's a deep team, a team that competes in a pretty tough conference,'' Campbell said. ''It helps when everybody can chip in.''
Logan Couture had two goals and Joe Thornton scored against his former team as San Jose finished its East Coast road trip at 2-2-1.
Patrick Marleau added two assists and Niemi made 28 saves.
''We moved it around we just didn't get many good looks,'' Couture said of the final four minutes. ''When we had a shot, the puck bounced on us. We didn't get pucks through and I don't even know if we got a good quality scoring chance.
''The power play needed to get us one there and it let the team down.''
The Bruins came into the game ranked 20th in the league on the power play, converting on just three of 22 opportunities, but capitalized on their first one Tuesday when Marchand's wrist shot sailed over Niemi's glove for his first goal of the season at 13:57 of the opening period.
''We talk a lot about if you can't score goals you at least want to get some momentum.'' Krug said. ''Tonight it's nice to actually see some of those go in.''
With Marchand in the box minutes later for a cross check, the Sharks answered on Couture's second of the season, a deflection off a wrist shot by Marleau at 16:28.
Boston made it 2-for-2 on power plays 6:54 into the second period when Krug netted his second of the season on a wrist shot only eight seconds into the man advantage.
After Couture tied it off a pass from Marleau with 3:45 left in the second, the Sharks struck again 37 seconds later on Thornton's second of the season.
Thornton, who played seven full seasons for Boston before being traded to San Jose early in the 2005 season, batted Joe Pavelski's shot out of midair and past Rask for a 3-2 lead.
Griffith then tied it 4:50 into the third, scooping up a loose puck in front of the net and beating Niemi to his glove side.
NOTES: This marked the 31st meeting between the two teams, with Boston holding a 17-9-5 edge. . Last season's game nearly one year ago in Boston, a 2-1 win by the Bruins, was decided on Krejci's game-winner with 0.8 seconds remaining. . Boston D Matt Bartkowski played in place of Kevin Miller, who is sidelined indefinitely after dislocating his right shoulder Saturday during a fight with Buffalo's Nicolas Deslauriers. . San Jose F James Sheppard (knee) was activated before the game following a rehab assignment for Worcester of the AHL. . San Jose allowed a first-period goal for the first time this season.