Inter now needs Real Madrid to manage at least a draw with Sheriff Tiraspol later in Spain to secure their spot in next month’s draw with a match to spare thanks to two archetypal Dzeko goals in the space of six minutes midway through the second half.
The Bosnia forward lashed Inter into the lead with a precision first-time strike from the edge of the area and then nodded home a header to put the San Siro in party mood after the hosts had wasted a host of chances and had two goals ruled out for tight decisions.
Inter top Group D on 10 points after their third consecutive win in the competition, a point ahead of Madrid and four away from Sheriff in third.
It was a huge win with Inter’s final group match at the Santiago Bernabeu against Madrid in a fortnight’s time.
Barella wasted a golden opportunity to give Inter the lead with 11 minutes on the clock, somehow skying when Ivan Perisic’s deflected cross fell to him only yards from the Shakhtar goal.
Then a flurry of gilt-edged chances came and went midway through the first half, with the San Siro crowd wondering how the scores were still level.
First Lautaro Martinez had two shots well blocked by Maycon in the 22nd minute after a lightning break from Barella, then Andrea Ranocchia headed a corner just wide before Ivan Perisic rolled home a calm finish only for the home fans to be silenced by an extremely tight offside decision.
Seconds later Dzeko looked on in horror as Anatolii Trubin scrambled to stop him from tucking home the opener after sloppy Shakhtar play out from the back.
Just four minutes had passed from Martinez’s chance to when Dzeko then had a header well saved by Trubin, and in the middle of all that Fernando blasted a shot wide when he had a teammate wide open in front of goal.
An already strange match took on a further bizarre turn just before the hour mark when Martinez brilliantly lashed home what he thought was the opener, only for the goal to be ruled out for his foul on Mykola Matviyenko while he was still celebrating and the stadium announcer was still bellowing out his name.
However moments later Dzeko did finally rattle in a goal that couldn’t be ruled out when after Matteo Darmian’s low shot was charged down at the end of a flowing break the Bosnian crashed in his ninth goal in all competitions this season.
And he made sure the home supporters would go home happy, heading home the impressive Perisic’s delicate cross in the 67th minute and celebrating with the delirious fans behind the goal.
Those supporters’ hearts were in their mouths with eight minutes left when Dodo charged into dozing Inter’s area and thumped a low shot off the near post which rolled across the goalline and somehow missed both lunging feet and the opposite post.
But that was that from Shakhtar and Inter are now achingly close to an objective they’ve failed to meet since the 2011/12 season.