Trailing 3-2 entering the final frame, the Canadiens tied it 5 1/2 minutes into the frame on Max Pacioretty's eighth of the season and Desharnais added the game-winner off a Pacioretty feed less than 4 minutes later.
Tomas Plekanec also scored for the Habs, who jumped over the Bruins into first place in the Northeast Division with the victory while improving to 8-0-3 in their last 11 games.
Peter Budaj turned aside 31 shots in the win.
Boston, meanwhile, saw its six-game winning streak snapped despite a goal and two helpers from Patrice Bergeron.
Tyler Seguin scored and Brad Marchand distributed three assists for the Bruins.
Tuukka Rask was touched for four goals on 26 shots in the loss.