Karim Benzema's double put Madrid 2-0 up before Pierre-Emerick Aubameyang and Marco Reus netted for Dortmund.
The point was enough to see the Germans finish top of the group ahead of Real.
Their double in Madrid means Dortmund better the 20 goals Manchester United (1998/99), Barcelona (2011/12) and Real Madrid (2013/14) had previously scored in the group stages.
Dortmund also helped set the record for the highest amount of goals in a single Champions League game when they routed Legia Warsaw 8-4 two weeks ago.
Aubameyang is Dortmund's top scorer in Europe this season with four goals.
Having scored their magic 21st two minutes from time, Reus credited his goal to Aubameyang, who put in a superb cross for the Germany winger to sprint onto.
"'Auba' was world-class with his pass and I was happy to get on the end of it -- the goal was 99 percent him and one from me," said Reus.