Jay Bothroyd headed QPR in front in the first half - the first time City have trailed this season - and after goals from Dzeko and David Silva turned things around, Heidar Helguson brought the hosts level.
Yaya Toure headed in the winner, but City had to hang on for a nervous final 10 minutes.
Manager Roberto Mancini was delighted to take the points from a tough encounter.
"When you play every three days, it is impossible, every game can be hard. QPR played very well but in the end it was important that we won.
"We had some problems with Samir (Nasri) before the game - his knee - and we can't take any more risks with him after so many games so it is better we did not need him because his knee is not good.
"It was hard in the second half, even though we played better and scored to make it 2-1. We had three or four chances to close the game, but when you don't close the game you take a risk because anything can happen."