A quickfire second-half Burnley double was cancelled out by a Sam Baldock penalty and a late Paul Anderson equaliser, before Chris McCann stole all three points for the visitors in the 96th minute in a pulsating 4-3 game at Ashton Gate.
In a closely-fought first half, Charlie Austin opened the scoring for the visitors after nine minutes.
The lead lasted just eight minutes, however, as Steven Davies replied for Bristol, finishing well in the 17th minute.
Davies could have extended the home side's lead twice in the 22nd minute, but missed the target on both occasions.
Tom Heaton saved well twice to keep City level, firstly on 25 minutes from Dean Marney and then in the 34th minute from a Martin Paterson header.
In the second half the game started to open up and Lee Grant had to be alert in the Burnley goal to keep out an effort from Jody Morris on 52 minutes.
Then Mark Wilson handled in his own box, giving Austin a chance to net his second from the spot. He duly obliged, slotting it low to the right to give Burnley a 2-1 lead on 59 minutes.
The 2-1 lead became 3-1 just a minute later when Paterson buried an effort, giving Bristol City a huge task to get anything from the game.
Cole Skuse fired over for the home side in the 62nd minute before Stephen McManus was brought down in the box in the 77th minute, which allowed Sam Baldock to pull a goal back for Bristol from the spot.
After some late pressure, Bristol City managed to find an equaliser, substitute Anderson netting in stoppage time to seemingly break Burnley hearts.
However, in the dying seconds Chris McCann restored Burnley's lead to give them a vital 4-3 win.