Logan Couture scored twice for San Jose (9-1-1), which won for the first time in four attempts at the Bell Centre since Dec. 2002.
Carey Price made 33 saves for Montreal (6-5-0).
After a scoreless first period in which San Jose outshot Montreal 11-8, Couture scored a power-play goal at 6:20 of the second period.
With the Montreal faithful calling for a tripping penalty on Couture, captain Joe Thornton sent a precise pass onto Couture's stick. The 24-year-old made no mistake from close range for his fifth goal of the year.
With the point, Thornton, who sits second in most assists amongst active players behind Jaromir Jagr, inched closer to a milestone. He now needs two more assists to reach 800 in his career.
The Habs' lack of discipline almost cost them again minutes after the goal when Couture rifled a shot past Price that hit the post.
Niemi made 15 saves after two periods en route to the shutout, his second of the season, and a league-leading ninth win.
Couture doubled the Sharks' lead at 4:09 of the third when a Patrick Marleau dump-in took an inexplicable bounce off the glass and landed on Couture's stick in front of a gaping net. Price, who had anticipated the puck behind his goal, couldn't get back in time.
Notes: The Canadiens and Sharks had not met since Dec. 1, 2011, when the Habs lost 4-3 in a shootout in San Jose. ... The injury-troubled Canadiens were without Daniel Briere (concussion), Max Pacioretty (hamstring), George Parros (concussion), and Brandon Prust (shoulder). ... Defender Dan Boyle has been out of the Sharks' lineup with a head injury since taking a hit from former Hab Maxim Lapierre on Oct. 15. The Sharks were also without forward Brent Burns (sore gums). ... Montreal heads to New York to play the Rangers on Monday, Oct. 28.