The victory snapped a tie for the second-most points in the Eastern Conference, giving the Canadiens 47. They lead the Northeast Division by a point over the Bruins.
In the shootout, all six Bruins players were stopped. The first five Canadiens couldn't score, either. Then Gallagher put the puck between Tuukka Rask's pads.
It capped a comeback after Boston had taken a 5-3 lead on Tyler Seguin's 11th goal of the season at 11:50 of the third period. Gallagher scored 28 seconds later, then Markov tied it on a power play.
With Aaron Johnson in the penalty box for delay of game, Markov's shot from the left point appeared to go in off the stick of Boston's Zdeno Chara.
Michael Ryder opened the scoring at 4:15 of the first period and P.K. Subban gave the Canadiens a 2-0 lead at 2:53 of the second. Then the Bruins, scored four goals in just over 14 minutes against goalie Carey Price. Dougie Hamilton started the comeback at 3:32 of the second, Brad Marchand tied it, Patrice Bergeron put Boston ahead and Nathan Horton made it 4-2 at 17:36 of the period.
Price was replaced by Peter Budaj to start the third period.
Ryder cut it 4-3 with his second goal of the game at 3:58 of the third period, but Seguin restored Boston's two-goal advantage.
FLAMES 4, AVALANCHE 3
CALGARY, Alberta (AP) — Mike Cammalleri scored twice in the second period and Calgary held off Coloradobefore trading captain Jarome Iginla to the Pittsburgh Penguins.
The Flames sent Iginla to the Eastern Conference-leading Penguins in exchange for U.S. college prospects Kenneth Agostino and Ben Hanowski and a first-round pick this year.
Iginla was announced as a healthy scratch two hours before the start of the game. He sat out for the first time since April 8, 2007, in Colorado, ending his consecutive games streak at 441.
Jiri Hudler and Steve Begin also scored, Blake Comeau had two assists, and Joey MacDonald made 27 saves. The Flames, ahead of only Colorado in the 15-team Western Conference, won their eighth straight game on home ice to improve to 13-15-4.
Jamie McGinn, Gabriel Landeskog and Ryan O'Reilly scored for Colorado. The Avalanche have lost three straight and seven of eight to drop to 11-17-4.
WILD 4, COYOTES 3, OT
ST. PAUL, Minn. (AP) — Mikko Koivu scored at 2:43 of overtime to give Minnesota a comeback victory over Phoenix on Wednesday night, extending the Wild's winning streak to seven and the Coyotes' skid to seven.
Koivu skated out from the corner and beat goalie Jason LaBarbera between the pads.
Minnesota tied it with 54.3 seconds left in regulation, with Ryan Suter scoring on a wrist shot from the left point with Wild goalie Niklas Backstrom off for an extra attacker.
Torrey Mitchell and Matt Cullen also scored for the Wild, and Backstrom stopped 24 shots.
Rob Klinkhammer, Boyd Gordon and Michael Stone scored for Phoenix. LaBarbera made 33 saves.
SHARKS 4, DUCKS 0
SAN JOSE, Calif. (AP) — Joe Pavelski scored a minute into the game to start a three-goal first period spree and Antti Niemi earned his second shutout of the season to help San Jose sweep a home-and-home series against first-place Anaheim.
Patrick Marleau and Brent Burns also scored in the opening 10 minutes and Niemi made 22 saves for the Sharks, who have back-to-back regulation wins for the first time in two months.
Tommy Wingels added a short-handed goal and two assists to get San Jose off to a strong start to a crucial seven-game homestand. The Sharks moved into a tie for seventh place with St. Louis in the Western Conference.
The Ducks followed up a 5-3 home loss to the Sharks by coming out completely flat in the return game. Anaheim has lost four straight games in regulation following a 12-game streak with at least one point. This is the Ducks' longest skid since Bruce Boudreau took over as coach Nov. 30, 2011.