MUNICH (AP) -- Bayern Munich beat BATE Borisov 4-1 to make sure of winning Group F and being seeded in the knockout stage of the Champions League on Wednesday.
Both teams finished with 10 men but Bayern managed to score twice while down a player.
Mario Gomez put Bayern ahead in the 22nd minute, before last season's runner-up lost defender Jerome Boateng to a straight red card in the 51st. But Thomas Mueller and Xherdan Shaqiri added goals for Bayern before BATE was also reduced to 10 men with a second booking for Denis Polyakov in the 69th.
David Alaba scored for Bayern in the 83rd, while Yegor Filipenko netted a consolation goal for the Belarus side in the 89th.
"We had problems at the start because they defended well, but we wanted to give our fans something before Christmas," Gomez said.
Bayern finished ahead of Valencia because of a better head-to-head record. Valencia won 1-0 in Lille to finish with Bayern on 13 points. BATE, which had already qualified for Europa League, finished third on six points. Lille was last with three.
Although Bayern was eager to avenge a 3-1 loss in Belarus -- one of its only two defeats this season -- coach Jupp Heynckes left seven regulars on the bench.
"I am very pleased because this line-up had never played together before," Heynckes said. "I have confidence in all my players."
Gomez, in his first Champions League start after coming back from ankle surgery, notched his 21st goal in the competition thanks to a good run by the diminutive Shaqiri on the left. Shaqiri sent in a useful low cross, and Gomez stretched out his foot to knock the ball into the net.
Boateng was sent off for a needless sliding tackle from behind on Artem Kontsevoi in BATE's half in the 51st.
But only three minutes later, Mueller doubled the lead after a quickly taken free kick by Toni Kroos. Bastian Schweinsteiger flicked the ball to Mueller, who tapped it in from close range.
Shaqiri, the shortest man on the pitch, somehow managed to sneak ahead of the towering Maksim Bordachev to head in a cross from Gomez to make it 3-0 in the 66th.
Three minutes later, Polyakov earned his second booking for diving in Bayern's penalty area.
Two late substitutes produced Bayern's fourth goal. Franck Ribery's corner wasn't cleared, allowing David Alaba to control the ball and then use the same left foot to drill it inside the post.
Filipenko's goal with time almost up was too little, too late for BATE.