Pep Guardiola's German giants were 3-1 winners over CSKA Moscow in the icy cold Russian capital thanks to goals from Arjen Robben, Mario Gotze and Thomas Muller.
Muller converted a 65th-minute penalty to seal the win, three minutes after Keisuke Honda had given CSKA brief hope.
Bayern will advance from Group D alongside Manchester City who toiled for a 4-2 win at home against Viktoria Plzen.
Defender Ramos was dismissed in the 26th minute, and 11 minutes later Gareth Bale gave Madrid the lead with a fine free-kick, only for the advantage to be almost instantly wiped out by Umut Bulut.
Alvaro Arbeloa and Angel Di Maria netted in the first 20 minutes of the second half, and Isco added a fourth goal for the hosts late on.
Benfica improved their prospects of joining Paris St-Germain in qualifying from Group C after beating Anderlecht 3-2 in Brussels.
Benfica moved level on points with Olympiacos in the battle for second place, after the Greek side lost 2-1 in Paris.
Zlatan Ibrahimovic put PSG ahead after just seven minutes, but the French capital side were down to 10 men early in the second half when Marco Verratti was sent off for a second yellow-card offence.
Kostas Manolas snatched an equaliser with 10 minutes remaining, but Edinson Cavani poked in a late winner for the Ligue 1 champions.
Manchester United were 5-0 winners away to Bayer Leverkusen to guarantee their Champions League campaign will continue into the new year.
Leverkusen fell to third place in Group A, one point behind Shakhtar Donetsk who beat Real Sociedad 4-0 thanks to goals from Adriano, Alex Teixeira and Douglas Costa, who netted twice.
Shakhtar face United at Old Trafford in the final round of group games, with Leverkusen away to winless Sociedad.
- Sports & Recreation
- Arjen Robben
- Keisuke Honda
- Mario Gotze
- Sergio Ramos
- Arturo Vidal
- Pep Guardiola