Darijo Srna put the Ukrainians, who are deep in a winter break and have not played competitively since the group stage, ahead with a sweetly-struck 31st-minute free-kick before the prolific Robert Lewandowski levelled 10 minutes later.
Douglas Costa restored the home team’s advantage in the 68th-minute before Hummels handed the Bundesliga outfit a second away goal with a header three minutes from the end.
Dortmund had begun the game well and were attacking confidently, and Lewandowski’s headed effort in the 10th minute gave Shakhtar a warning. A goal for the Germans seemed inevitable as Marco Reus showed some fine touches and Blaszczykowski continued to take up dangerous position.
Hummels almost provided it when he met Reus’ corner in the 17th minute, only for his header to come back off the crossbar.
Reus stung Andrei Pyatov’s hands with a rasping effort but Shakhtar gradually started to find their feet, Taison proving a lively outlet. And with 31 minutes gone, the hosts found themselves in front.
Felipe Santana fouled Luiz Adriano to concede a free-kick 25 yards from goal and Srna stepped up to whip the ball over the wall and beat the flailing Roman Weidenfeller.
Dortmund had their equaliser in the 41st minute. Mario Gotze had two attempts at his cross after a botched clearance from Dimitro Chygrynskiy and Lewandowski wrong-footing the defence when he fortuitously miscontrolled the ball, but finished clinically.
Dortmund put together a fine move immediately after the restart but were denied the finishing touch when Reus’ shot was blocked.
The game had slowed somewhat from the first period, with fewer clear-cut chance but Dortmund looked more likely to get a second.
But for the second time, Shakhtar defied the run of play to take the lead with 22 minutes left. Chygrynskiy pumped the ball long and Hummels failed to deal with it to leave Costa, who had surprisingly replaced Taison, to take it down neatly and send a wonderful strike beyond Weidenfeller.
Lewandowski and Gotze combined to fashion a swift response but this time the Polish striker sent his volleyed effort wide.
With three minutes to go, Dortmund deservedly equalised — Hummels making up for his earlier error with the crucial touch.
Marcel Schmelzer was the provider with an outswinging corner and Hummels left no doubt with a decisive header.
SHAKHTAR DONETSK: Pyatov, Srna, Rakitskiy, Chygrynskiy, Rat, Fernandinho, Hubschman, Alex Teixeira (Eduardo 83), Mkhitaryan, Taison (Douglas Costa 62), Luiz Adriano.
BORUSSIA DORTMUND: Weidenfeller, Piszczek, Felipe Santana, Hummels, Schmelzer, Kehl, Bender, Blaszczykowski (Leitner 80), Gotze, Reus (Schieber 90), Lewandowski.
Referee: Howard Webb (England).