Raffaele De Vita came off the bench to head Swindon into the second round of the Carling Cup.
Paolo Di Canio's side bossed the game against their Championship opponents and hit the deserved winner in the 71st minute.
Spanish winger Lander Gabilondo found De Vita for an easy header past former England goalkeeper David James.
Bristol City were lacklustre throughout but had their best chance when Brett Pitman drove wide.
Swindon - who won the League Cup in 1969 - will now face Southampton in round two.
Playing in one of the first round ties delayed by the riots earlier in the month, Swindon made a flying start.
They should have scored when Leon Clarke got on the end of Callum Kennedy's cross, but his close-range effort was blocked by City defender Lewin Nyatanga.
Matt Ritchie then scuffed his shot wide from six yards out before Pitman fired wide at the other end.
The game was heading for extra time before Gabilondo picked out De Vita to send his header across the face of goal and into the far corner.