Ottawa came from a goal behind in both the first and third periods, but could not get one past Carey Price in the shootout. The Senators suffered their 10th extra time loss of the season.
Desharnais put a low backhand shot between the pads of Ben Bishop in the second round and Price made it stand up. Price stopped 35 shots in regulation and overtime.
Erik Cole gave Montreal the lead 13:45 into the game, but Colin Greening tied it just 26 seconds later.
Desharnais scored 24 seconds deep in the third only to have Erik Karlsson deadlock the contest again with 8:59 to go in regulation.
Bishop made 24 saves.
Ottawa, which is in seventh place in the Eastern Conference, moved within a point of Boston for the lead in the Northeast Division.
McPhee, Cokas 'working on their marriage' after affair
Astronomers offer more expansive view of universe