Tomas Tatar and Jeff Petry each had two assists, and Jake Allen made 22 saves for the Canadiens (20-15-9), who lost 4-1 here Monday in the first of the two-game set.
"I think we have to look back on this game and continue to build on that performance," Anderson said. "I thought we played a solid game, I thought everybody was engaged, and all four lines were rolling. Jake back there was a wall for us and gave us a really good shot at winning tonight."
Connor McDavid had a goal and two assists, and Ryan Nugent-Hopkins scored in his return from an upper-body injury for the Oilers (27-16-2), who lost at home for the first time in nine games. Mike Smith made 27 saves.
Nugent-Hopkins and Jesse Puljujarvi scored 1:01 apart late in the third period with Smith pulled for the extra skater to get Edmonton within one.
"They didn't give up a whole lot all night, through the neutral zone or the [offensive] zone," said Nugent-Hopkins, who missed the previous four games. "As the game went on, I thought we started breaking them down better. That was a tight-checking game on both sides, and they capitalized on a couple of opportunities they had, and we did at the end too, but we were just a little short at the end. It's a hard-fought game, that's the way all the games are going to be down the stretch, and obviously in the [Stanley Cup] Playoffs, the same mindset."
The Oilers are in third place in the seven-team Scotia North Division, one point behind the second-place Winnipeg Jets. The Canadiens are in fourth, eight points ahead of the Calgary Flames. The top four teams will qualify for the playoffs.
Artturi Lehkonen scored on a backhand from in close with 29 seconds remaining in the first period to give Montreal a 1-0 lead.
McDavid scored on a breakaway at 3:09 of the second period to tie it 1-1, but Anderson scored 11 seconds later to put the Canadiens ahead 2-1 at 3:20.
"McDavid can get behind the D pretty quick," Montreal coach Dominique Ducharme said. "We were changing, and it was not a bad change because we had the puck in the [offensive] zone. The way we reacted and [Anderson's] goal right after, I think it was just the mindset of our team tonight. It felt right for the guys, and obviously it brought some positives."