Inter now need Real Madrid to manage at least a draw with Sheriff Tiraspol later 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 Bosnian forward lashed Inter into the lead with a precise 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.
"We really needed this win, after a first half in which we created so much and we were still 0-0 with a team like them there was a bit of tension. Dzeko's goal was a liberation," Inter coach Simone Inzaghi told Sky Sport Italia.
"(The last 16) is a big target for us. When I came here I spoke about it with the club... we played really well, let's not forget that we're a little more than 48 hours from a match like the one against Napoli (won 3-2 on Sunday) in which we expended a lot of energy."
For Shakhtar, defeat leaves them rooted to the bottom of the group with a solitary point, their European season over.
"We deserved to lose today, we played with little courage, a little personality and little quality. We lost against a team that's doing well, that's a great team," said Shakhtar coach Roberto De Zerbi.
It was a huge win, with Inter's final group match at the Santiago Bernabeu against Madrid in a fortnight's time, and it was one with plenty of incidents.