Nigel Pearson was given a winning start to life as Bristol City manager as they came from behind to win 3-1 at Swansea in the Sky Bet Championship.
Kasey Palmer looked as though he had gifted his old side victory when he handled in the box to allow Andre Ayew to give the hosts a deserved lead from the penalty spot.
But Nahki Wells equalised started the comeback, Palmer scored direct from a corner, then Antoine Semenyo sealed City's second win in a week to give Pearson the dream start to life as manager.
Pearson watched on from the stands as his new side overcame Middlesbrough at the Riverside to end their run of six successive Championship defeats.
And the experienced former Leicester and Watford manager kept the faith with the same starting XI for the trip to south Wales.
It took some last-ditch defending and heroic goalkeeping from Daniel Bentley to keep Swansea at bay in the first half.
The Robins goalkeeper produced a reaction save to push Jamal Lowe's fierce half-volley over the bar, before using his midriff to deny Yan Dhanda as the Swans consistently found routes through the defence.
The one-way traffic continued as the half wore on, but the hosts failed to capitalise.
Adrian Mariappa came to the rescue five minutes before half-time to clear Ben Cabango's effort off the line, before Bentley made another important save from Conor Hourihane's header to keep it goalless.
Pearson hauled defender Ryley Towler off just before the half-time, but the change could not prevent Swansea finding the breakthrough in the 54th minute through Palmer.
The man who spent the first half of the season on loan at the Liberty Stadium used his arm to stop a Matt Grimes ball reaching Jake Bidwell at the back post.
Referee Keith Stroud pointed to the spot and Ayew calmly beat Bentley to net his 10th goal of the season.
But a tactical switch from Pearson to put centre-back Zak Vyner in midfield bore fruit as the visitors got themselves back on level terms 10 minutes later.
Vyner pressed high to pounce on a loose ball that was missed by Marc Guehi. He then had the composure to pick out Wells with a low cross, and the striker beat Freddie Woodman with a low drive.
Woodman was then caught out by former team-mate Palmer, who struck a curling corner high beyond his reach to spark celebrations on the Bristol City bench with 10 minutes remaining.
And Semenyo ensured Swansea gave up ground on their promotion rivals by closing down Woodman to block a clearing kick, before tapping home the rebound in the 90th minute.
What the managers said...
Swansea's Steve Cooper: "In the first half the game should have been doing and dusted and we should have been two or three goals up, at least. We didn't take our chances but still managed to start the second half just as well and we had complete dominance in the game.
"It was a one-sided affair, we went 1-0 up but we did not handle it well, which is something we have done really well this year. It was unlike us."
Bristol City's Nigel Pearson: "It looked unlikely during the first half. Swansea were by far the better side - they dominated possession, our quality on the ball was poor because we had to work so hard out of possession that you expend an awful lot of physical and mental energy.
"I have to give our players an unbelievable amount of credit for the way that we stuck at defending and were prepared to put our bodies on the line. One of the things that we've talked about this week is stopping crosses because Swansea are very much a team that create a lot of potential in wide areas and I thought we were very good in that all game.
"Let's not kid ourselves, we were second best in the first half and we couldn't have had any complaints had we come in two, three goals down. It was a really tough half for us. But yes, shows you what football is like."