Buffalo's Thomas Vanek had two assists and also scored in the shootout, while the Canadiens failed on their two shootout attempts - the last when Alex Kovalev had goaltender Ryan Miller down, but snapped his shot off the right post.
Vanek then scored on his shootout, snapping a shot past Cristobal Huet.
The Sabres won their home opener with a wild finish, three times overcoming two-goal deficits and twice in the third period.
Daniel Briere, Jiri Novotny and Jason Pominville also scored in regulation, giving Buffalo a win in its home opener and its second consecutive shootout win. The Sabres were coming off a 3-2 shootout win at Carolina on Wednesday.
Saku Koivu had two goals and an assist for Montreal, while Chris Higgins had a goal and two assists and Michael Ryder added a goal and an assist.
And the Sabres comeback got a booing crowd - unhappy with the officials after the Sabres were penalized three times in a 74-second span - on its feet when Afinogenov forced overtime.
The tying goal came with the Sabres' net empty and was set up by co-captains Briere and Chris Drury, who dug the puck out from behind the Montreal net. Drury fed it in front to Vanek, whose shot dribbled under Huet, allowing Afinogenov to poke it in the open side.
The Canadiens appeared to have the game in hand several times, the last when Koivu scored - converting Kovalev's pass through the crease - during a two-man advantage with eight minutes left to put Montreal up 4-2.
Briere got the crowd roaring when he scored four minutes later on a partial breakaway, splitting two Montreal defenders and beat Huet through the legs.
The Sabres won despite a power-play that continues to fizzle, going 0-for-5 against Montreal - including an 88-second, two-man advantage - and has yet to capitalize on 14 chances. That's a considerable dropoff for a unit that returns mostly intact and was the NHL's third-best last year.
Notes: The Canadiens, who play at Toronto on Saturday, open with a three-game road trip before hosting Ottawa on Oct. 14. ... Despite their success last season in reaching the Eastern Conference final, the Sabres' average ticket price of $30.07 is third-lowest in the NHL, according to Team Marketing Report. Buffalo's season-ticket base of about 14,500 has more than doubled from last year. ... Canadiens D Craig Rivet played his 600th career game.