Striker Nile Ranger netted a late winner as Swindon edged past struggling Bristol City.
Aden Flint's header against his former club put the visitors ahead before Swindon loanee Nicky Ajose drilled home an equaliser.
Jay Emmanuel-Thomas lashed in an impressive strike to restore City's lead, but Ajose levelled to make it 2-2 at the break.
The game was heading for a draw when Ranger rifled home to snatch the win.
City remain without a win in League One this season and were left frustrated after twice throwing away a lead.
Bristol City wait for a win
Sean O'Driscoll's Bristol City have not won a league game since 9 March, when they beat Middlesbrough in the Championship.
Flint, who joined City in the summer for a reported £300,000, opened the scoring in an entertaining first-half with a header at the back post from Marlon Pack's corner.
Striker Ajose brought the hosts level with his first goal of his five-month loan spell with Town, driving home a low strike past keeper Frank Fielding.
The Swindon defence allowed in-form Emmanuel-Thomas to cut in off the right and lash the ball in for his seventh goal of the season.
But City's lead lasted only seven minutes before Ajose poked home his second from Massimo Luongo's centre to make it 2-2 at the break.
Dany N'Guessan had the ball in the back of the net for Swindon in a flat second half, but it was disallowed for a shirt pull in the build-up.
Ajose went close to grabbing his hat-trick but his simple effort was kept out by Fielding, while at the other end Sam Baldock failed to find the end of Joe Bryan's cross.
In the 87th minute, former Newcastle forward Ranger turned his defender and blasted it home to earn Mark Cooper's side all three points.
VIEWS FROM THE DRESSING ROOM
Swindon Town manager Mark Cooper told BBC Wiltshire:
"We had to win a different kind of game, a real battle, and we had to win a different kind of way which is very pleasing.
"I'm really pleased for the boys that came in. We suffered some injuries later on in the week which disrupted our preparation.
"We weren't at our best today, we played with our hearts rather than our heads.
"We let them know at half-time that the way we played wasn't acceptable."
Bristol City head coach Sean O'Driscoll told BBC Radio Bristol:
"It's been a frustrating season, not just for me but for everybody.
"But you spend your life in football being frustrated and disappointed and have rare moments of jubilation and success.
"The players have been really good and dusted themselves down from the game in midweek.
"They came out focused and full of confidence. We've created chances and people have got to find solace in that."
- 01 Foderingham
- 02 Thompson
- 05 Hall
- 14 McEveley
- 22 Ward
- 04 Luongo
- 12 N'Guessan (El Gabbas - 90' )
- 15 Kasim Booked
- 19 Thompson Booked
- 33 Ajose
- 09 Ranger
- 25 Belford
- 23 Barthram
- 29 Rossi-Branco
- 37 Wood
- 38 Walsh
- 20 Storey
- 34 El Gabbas
- 01 Fielding
- 03 Williams (Bryan - 46' )
- 05 Flint Booked
- 24 O'Connor (Cunningham - 52' )
- 02 Moloney
- 11 Wagstaff Booked
- 21 Pack
- 22 Shorey (Harewood - 89' )
- 25 Elliott
- 09 Baldock
- 10 Emmanuel-Thomas
- 13 Parish
- 17 Cunningham
- 14 Reid
- 27 Burns
- 28 McLaughlin
- 15 Bryan
- 23 Harewood
Live Text Commentary
Full Time The final whistle goes and the game is over.90:00 +4:46 Substitution
Substitution Mohamed El-Gabbas comes on in place of Dany N'Guessan.90:00 +3:40
Darren Ward manages to make a clearance.90:00 +3:31
Brendan Moloney takes a shot and bounced off the bar.90:00 +2:35
Free kick taken by Wes Foderingham.90:00 +2:13
The referee blows for offside against Jay Emmanuel-Thomas.90:00 +0:37
Free kick taken by Marlon Pack.89:34 Booking
The referee shows Yaser Kasim a yellow card for unsporting behaviour.89:29
Yaser Kasim challenges Joe Bryan unfairly and gives away a free kick.88:11 Substitution
Substitution Marlon Harewood replaces Nicky Shorey.87:35
Marlon Pack challenges Massimo Luongo unfairly and gives away a free kick.86:36 Goal scored
Goal! - Nile Ranger - Swindon 3 - 2 Bristol C Nile Ranger scores with a right foot finish. Swindon 3-2 Bristol City.86:21
Clearance by Scott Wagstaff.86:12
Corner from the right by-line taken by Yaser Kasim.84:06
Corner taken by Jay McEveley from the right by-line.82:46
Free kick taken by Nathan Thompson.82:42
Free kick awarded for a foul by Marlon Pack on Louis Thompson.82:15
Corner from the left by-line taken by Jay McEveley.81:35
Free kick taken by Jay McEveley.
Aden Flint is cautioned.81:13
Aden Flint concedes a free kick for a foul on Nick Ajose.80:48
Free kick taken by Yaser Kasim.80:41
Foul by Marlon Pack on Louis Thompson, free kick awarded.79:03
Dany N'Guessan takes a shot. Frank Fielding catches the ball.78:23
Frank Fielding restarts play with the free kick.78:18
Unfair challenge on Scott Wagstaff by Nile Ranger results in a free kick.76:56
Joe Bryan delivers the ball.72:26
Nick Ajose takes a shot. Frank Fielding blocks the ball.70:35
Nick Ajose takes the chance to get an effort at goal.69:10
Nick Ajose takes the chance to get an effort at goal and missed to the left of the target.67:14
Aden Flint restarts play with the free kick.67:00
Nile Ranger challenges Aden Flint unfairly and gives away a free kick.64:27
Free kick taken by Wes Foderingham.64:22
Sam Baldock is ruled offside.59:15
Aden Flint takes the free kick.59:05 Booking
Louis Thompson receives a yellow card.59:01
Unfair challenge on Brendan Moloney by Louis Thompson results in a free kick.57:53
Grant Hall makes a clearance.57:30
Free kick taken by Nicky Shorey.57:20
Scott Wagstaff fouled by Jay McEveley, the ref awards a free kick.55:27
Frank Fielding restarts play with the free kick.55:22
Free kick awarded for a foul by Dany N'Guessan on Aden Flint.52:47
Shot by Jay Emmanuel-Thomas. Wes Foderingham catches the ball.51:38 Substitution
Substitution Greg Cunningham on for James O'Connor.46:58
Nicky Shorey takes the free kick.46:35
Unfair challenge on Scott Wagstaff by Jay McEveley results in a free kick.46:08
Shot by Dany N'Guessan missed to the right of the target.45:01
The referee blows the whistle to start the second half.45:01 Substitution
Substitution Joe Bryan on for Derrick Williams.45:00 +2:14 Half time
Half Time The referee calls an end to the first half.45:00 +1:57
Free kick crossed by Jay McEveley.45:00 +1:46
Derrick Williams gives away a free kick for an unfair challenge on Dany N'Guessan.45:00 +0:32
James O'Connor makes a clearance.45:00 +0:21
Corner from the left by-line taken by Jay McEveley.43:25
Clearance by James O'Connor.43:14
Corner taken by Jay McEveley.42:14 Goal scored
Goal! - Nick Ajose - Swindon 2 - 2 Bristol C Nick Ajose grabs a goal with a right foot finish. Swindon 2-2 Bristol City.41:11
Clearance by Wes Foderingham.39:54
Shot by Jay Emmanuel-Thomas cleared the crossbar.39:42
Corner taken by Nicky Shorey from the left by-line.37:54
Clearance by Jay Emmanuel-Thomas.37:37
Jay McEveley crosses the ball in from the free kick.37:32
Derrick Williams challenges Massimo Luongo unfairly and gives away a free kick.36:53
Yaser Kasim takes the free kick.36:47
Foul by Derrick Williams on Nile Ranger, free kick awarded.35:06 Goal scored
Goal! - Jay Emmanuel-Thomas - Swindon 1 - 2 Bristol C Jay Emmanuel-Thomas scores with a left foot finish. Swindon 1-2 Bristol City.35:06
Assist on the goal came from Brendan Moloney.35:06 Goal scored
Goal! - Jay Emmanuel-Thomas - Swindon 1 - 2 Bristol C Jay Emmanuel-Thomas grabs a goal with a left foot finish. Swindon 1-2 Bristol City.32:53
Corner from the left by-line taken by Nicky Shorey.31:38
Corner taken by Nick Ajose from the left by-line.31:16
Louis Thompson takes a shot.29:57
Brendan Moloney takes the chance to get an effort at goal and missed to the right of the goal.29:17
Clearance by Nile Ranger.29:08
Corner from the left by-line taken by Nicky Shorey.28:53
Clearance by Nathan Thompson.28:48
The ball is sent over by Brendan Moloney.24:32
Free kick taken by Wes Foderingham.24:28
The referee blows for offside against Nicky Shorey.22:02
The ball is delivered by Jay McEveley.20:29
Dany N'Guessan takes a brilliant shot and strikes the post.19:33
Free kick taken by Grant Hall.19:23
Unfair challenge on Louis Thompson by Marlon Pack results in a free kick.18:17
Nathan Thompson provided the assist for the goal.18:17 Goal scored
Goal! - Nick Ajose - Swindon 1 - 1 Bristol C Nick Ajose slots the ball right footed into the goal. Swindon 1-1 Bristol City.17:54
Free kick taken by Darren Ward.17:47
Free kick awarded for a foul by Marvin Elliott on Yaser Kasim.17:04
Louis Thompson takes the chance to get an effort at goal and missed to the left of the net.13:25
Clearance by Wes Foderingham.12:31
Darren Ward makes a clearance.12:08
Frank Fielding restarts play with the free kick.12:04
Dany N'Guessan gives away a free kick for an unfair challenge on Marvin Elliott.11:17
Marvin Elliott takes a shot and went wide of the right hand upright.11:08
The ball is swung over by Nicky Shorey.10:34
Frank Fielding restarts play with the free kick.10:31
The assistant referee flags for offside against Nile Ranger.10:02
Clearance made by Scott Wagstaff.9:57
Corner from the left by-line taken by Jay McEveley.9:46
Clearance by Brendan Moloney.8:33
Marlon Pack provided the assist for the goal.8:33 Goal scored
Goal! - Aden Flint - Swindon 0 - 1 Bristol C Aden Flint scores a headed goal. Swindon 0-1 Bristol City.8:00
Corner from the left by-line taken by Marlon Pack.5:28
Marlon Pack has an effort at goal and missed to the left of the goal.5:14
Clearance by Darren Ward.4:54
Nicky Shorey crosses the ball in from the free kick.4:50
Massimo Luongo concedes a free kick for a foul on Derrick Williams.3:38
Frank Fielding takes the free kick.3:34
Nicky Shorey fouled by Dany N'Guessan, the ref awards a free kick.2:45
Free kick taken by Darren Ward.2:27
Scott Wagstaff goes into the referee's book.2:27 Booking
Free kick awarded for a foul by Scott Wagstaff on Louis Thompson.1:31
Frank Fielding restarts play with the free kick.1:17
The assistant referee signals for offside against Nick Ajose.1:02
Darren Ward restarts play with the free kick.0:49
Marlon Pack concedes a free kick for a foul on Louis Thompson.0:00
The game gets underway.
Live data and text provided by our data suppliers