Real were poor defensively and a rapid attack ended with Bruno Henrique setting up Max Arnold for the second. Wolfsburg could have scored more goals, while Real had few clear chances.
Karim Benzema tapped in to put Real in front before Shakhtar had Taras Stepanenko sent off. Ronaldo scored a penalty after Darijo Srna was controversially punished for handball and added another spot-kick when Marcio Azevedo handled.
The result - which means Barca have lost back-to-back league games, after their Clasico defeat to Real Madrid - means that Atletico Madrid now sit just three points behind La Liga leaders Barca, with Real a further point back.
Barcelona got their La Liga title defence off to the perfect start with a comfortable home win over Real Betis in which Lionel messi scored twice and Luis Suarez grabbed a hat trick.