LISBON, Portugal (AP) " Defending champion Real Madrid advanced from the group stage of the Champions League for the 20th straight time after beating 10-man Sporting Lisbon 2-1 on Tuesday.
Karim Benzema came off the bench to get the late winner in the 87th minute.
A draw would have been enough to get Madrid through to the knockout stages anyway, but victory gave the team a chance to finish first in Group F " with a home victory over Borussia Dortmund in the final round.
"It was important that we won here," Madrid coach Zinedine Zidane said. "We achieved what we came to get. We are going to play a final against Dortmund now."
The German side, which routed Legia Warsaw 8-4, has a two-point lead over Madrid.
Benzema salvaged Madrid's victory with a header after a well-placed cross by Sergio Ramos. That came just seven minutes after Sporting midfielder Adrien Silva equalized by converting a controversial penalty kick. The penalty was awarded after the ball hit Fabio Coentrao's arm, which he had just thrust into the air to complain of a hand ball by Sporting.
"We had our difficult moments in the game but that's normal," Zidane said. "But we managed to score a wonderful second through Karim Benzema."
Benzema had been doubtful to play during the week because of an injury but his recovery proved crucial. He entered the match in the 67th to replace Francisco "Isco" Alarcon.
Portugal forward Cristiano Ronaldo, returning home to play against the team where he started his career, got an assist in Madrid's first goal when he mis-hit a shot inside the area. The ball bounced off his back foot and moved forward for Raphael Varane's easy shot from close range in the first half.
It was the third straight game for Ronaldo without a goal in the Champions League, keeping him two short of becoming the first player to reach the 100-goal mark in European competitions.
Sporting's Joao Pereira was sent off in the 64th with a straight red after an altercation with Madrid's Mateo Kovacic.
"We were great both technically and tactically. We only missed a few details," Sporting coach Jorge Jesus said. "In Madrid we were not able to defend our lead after 87 minutes and tonight the red card to Joao Pereira was decisive."
Madrid scored two late goals " the first in the 89th " in the 2-1 win over Sporting in the teams' opener in the group stage.
Gareth Bale limped off the field on Tuesday after being substituted because of an apparent ankle injury in the 58th.
The game marked Madrid's return to Lisbon for the first time since winning the 2014 Champions League against Atletico Madrid at the Estadio da Luz.
The victory extended Madrid's unbeaten streak to 30 matches in all competitions. The Spanish club has scored 25 goals in its last six away games.
This story has been automatically published from the Associated Press wire which uses US spellings