Bristol City needed extra time to see off Swansea in their Carling Cup tie at Ashton Gate but needed a controversial penalty to seize the initiative.
Lee Peacock started and finished the scoring for Bristol City
New signing Karl Connolly levelled for the Swans just after Lee Peacock had opened the scoring in the first half.
No more goals followed in normal time, but Swansea wing Brad Maylett was sent off after wrestling Bristol defender Matt Hill to
Facing the whole of extra time with 10 men, Swansea manager Brian Flynn opted to keep both Connolly and Lee Trundle up front and let midfield take the strain.
Swansea had dominated for a long spell in the second half, when their
midfielders Leon Britton and Roberto Martinez ran the show.
Yet within six minutes the bold plan unravelled as referee Clive Penton awarded a harsh penalty for hand ball against Kris O'Leary, after he was unable to get out of the way of a fierce shot.
Mickey Bell duly converted the spot kick past Brian Murphy and there was no way back for Swansea from there.
Danny Coles added a third for Bristol soon after, with Peacock grabbing his second at the end to book a place in the second round.
Bristol City: Phillips, Carey, Butler, Coles, Hill, Wilkshire, Burnell, Doherty, Bell, Peacock, Miller.
Subs: Tinnion, Stowell, Matthews, Roberts, Woodman.
Swansea: Murphy, Jones, O'Leary, Johnrose, Hylton, Maylett,
Britton, Martinez, Durkan, Trundle, Connolly.
Howard, Nugent, Thomas, Coates.
Referee: Clive Penton (Sussex).