The Bundesliga outfit had led for most of the game until the German international struck with one minute remaining.
However, he could do nothing to stop Marco Reus's fine volley in the 28th minute. The German international struck the ball past Casillas at his near post from Lewandowski's lofted through ball.
Pepe drew Real back on level terms with a bullet header from Mesut Ozil's centre, but Dortmund were back in front on the stroke of half-time. Mario Gotze looked to have nudged the ball past Casillas as he bore down on goal, but officials ruled it was an own goal by Alvaro Arbeloa.
Jose Maria Callejon nearly drew the hosts level, but his effort was cleared off the line by Grosskreutz.
When Real won a free kick with the seconds ticking away, Cristiano Ronaldo was expected to have a go at goal, but it was Ozil who took it and found a way past Roman Weidenfeller.
Jurgen Klopp's men still had one more chance to win the game however, as Subotic nearly got his head to the ball from a corner in the final minute of time added on.