Having beaten Ajax 1-0 at home and only been denied a win at Manchester City three weeks ago by a late penalty in the 1-1 draw, the German champions produced another battling European display at home against Jose Mourinho’s Madrid.
“It was a strange match, neither team was better, but it was an incredibly difficult game,” said Mourinho.
“They were very organised and defended very well. Dortmund deserved the victory, but we had our chances to win the game.”
An opening goal by Dortmund’s Robert Lewandowski was immediately cancelled out by Real’s Cristiano Ronaldo in the first-half before Schmelzer’s 64th-minute winner.
“It feels overwhelming, it was a sensational evening, you can only imagine something like this in your wildest dreams,” said Dortmund coach Jurgen Klopp.
Defeat drops Real to second in the group on six points with Dortmund top on seven, but the teams meet again at the Santiago Bernabeu stadium in a fortnight.
Despite having been European champions nine times, Real continued their appalling record on German soil and in their 24 matches in Germany they have now suffered 17 losses and their single victory was 12 years ago.
Dortmund produced a highly disciplined display as they bounced back from losing the Ruhr derby 2-1 at home to Schalke in the Bundesliga on Saturday to claim victory despite only around 40 percent possession.
“It was important for us to show a reaction after losing at the weekend,” said Schmelzer. “We must be realistic, but we can also be consist in Madrid.”
Both Schmelzer and midfielder Mario Götze, who missed the Ruhr derby with injury, returned to the starting line-up, while Mourinho made three changes to the team which won 2-0 at Celta Viga on Saturday in La Liga.
Germany midfielder Sami Khedira, who lasted only 20 minutes before going off clutching his left hamstring, France’s Karim Benzema and Argentina’s Angel Di Maria boosted an already powerful line-up.
Captain Ilker Casillas made his 125th European appearance in front of a capacity crowd of 65,829.
Both sides had early chances as Lewandowski wasted a great shooting position on 16 minutes to fire just left of goal, while Di Maria fired over for Real on 21 minutes.
Luka Modric came into the Real midfield for the injured Khedira, but Dortmund began to find some space to exploit with captain Sebastian Kehl firing over approaching the half hour mark.
Dortmund took a deserved lead after a rare mistake by Real’s Pepe saw Kehl snatch possession to thread a pass through the Madrid defence for Lewandowski to fire home on 36 minutes.
With the home crowd still celebrating, the lead lasted just two minutes as a superb pass from Germay’s Mesut Özil found Ronaldo who lifted the ball over Dortmund goalkeeper Roman Weidefeller and into the net.
It was his fifth goal of the competition as it stayed 1-1 at the break.
Only a reflex save from Casillas kept Dortmund out as Germany midfielder Mario Goetze unleashed a fierce shot in the 50th minute as Borussia laid siege to the Real goal.
At the other end, di Maria fired across the goal and just wide of goal with both Weidenfeller and the Dortmund defence at sea in the 55th minute.
Both Sergio Ramos and Xabi Alonso picked up second-half yellow cards for rough defending as Borussia kept pushing forward and were rewarded with their second when Schmelzer fired home from the edge of the area on 64 minutes.
Real burst into life after falling behind and Dortmund’s defence found themselves working over time to keep Madrid at bay and hold on for victory.