MADRID — With a late equalizer by substitute Marco Reus, Borussia Dortmund drew 2-2 with defending champion Real Madrid on Wednesday to win Group F and set a scoring record of 21 goals in the group stage of the Champions League.

Karim Benzema netted in each half at the Santiago Bernabeu Stadium to give Madrid a 2-0 lead, but forward Pierre-Emerick Aubameyang pulled the German side closer in the 61st and Reus struck the equalizer in the 88th.

"In the end it was a happy outcome for us," Dortmund coach Thomas Tuchel said. "It was very important to stand up to Real Madrid twice. We played full of courage."

Dortmund had already drawn 2-2 with Madrid when they met in Germany.

Madrid was left with the consolation prize of matching the club's 34-game unbeaten streak that had stood since the late 1980s.

"We had a lot of opportunities to put the game away and we didn't," Madrid coach Zinedine Zidane said. "We played a good match but couldn't get the win, now we have to move on. In the end it was well-deserved for them (Dortmund) for what they have done so far."

Dortmund finished the group with 14 points, two more than Madrid. Legia Warsaw, which defeated Sporting Lisbon 1-0 in Poland, finished third with four points to qualify for the Europa League.

"To win the Champions it doesn't matter if you are first or second in the group," Benzema said. "You have to beat all the teams."

Cristiano Ronaldo was held scoreless for the fourth straight time in the Champions League, again missing the chance to become the first player to score 100 goals in European competitions. His total remains at 98.

Benzema opened the scoring from close range in the 28th, completing a low cross by Dani Carvajal from the right flank. The Frenchman added to the lead in the 53rd with a firm header after a well-placed cross by James Rodriguez.

Aubameyang scored from inside the area and then set up Reus' equalizer after a quick counterattack.

Aubameyang's goal helped Dortmund match the previous record of 20 group-stage goals, a mark that had been achieved by three other clubs: Barcelona, this season and in 2011-12, Madrid in 2013-14 and Manchester United in 1998-99.

Dortmund's campaign this season included 6-0 and 8-4 routs against Legia.

The draw allowed Zidane's team to match Madrid's unbeaten run set under coach Leo Beenhakker in the 1988-89. Madrid hasn't been defeated since April at Wolfsburg in the quarterfinals of last season's Champions League.

"It's important to continue to make history and continue our good run," Zidane said.

Ronaldo's best chance on Wednesday was a close-range shot that struck the far post in the 78th minute. He had also come close 10 minutes earlier with a right-foot strike that forced a difficult cross-handed save by Dortmund goalkeeper Roman Weidenfeller.

He remains the competition's all-time leading scorer with 95 goals, two more than Lionel Messi, who netted his 93rd in Barcelona's 4-0 win over Borussia Moenchengladbach on Tuesday. It was Messi's 10th goal in the group stage, one short of Ronaldo's record of 11 achieved last year.

Ronaldo only scored two goals in this season's group stage, his worst mark since joining the Spanish club in 2009.

___

Tales Azzoni on Twitter: http://twitter.com/tazzoni