Danny Ward was Cardiff's late-goal hero as they boosted their Sky Bet Championship play-off hopes with a 1-0 win over Bristol City, who sacked Lee Johnson shortly after the full-time whistle.
The substitute ran on to a through ball from fellow replacement Lee Tomlin to slot a left-footed shot past Dan Bentley after poor control from City sub Benik Afobe had surrendered possession.
For the Robins, it meant nine games without a win - and four straight defeats since the season's resumption last month - and the result almost certainly ended already flickering play-off hopes.
Johnson recalled Tomas Kalas in place of suspended defender Ashley Williams and also brought in Famara Diedhiou to add a physical presence up front in a 4-4-2 formation.
Bristol City's statement in full
"Lee Johnson was this evening relieved of his role as Bristol City Head Coach.
"Current Assistant Head Coach Dean Holden will take over immediately in a caretaker capacity as the club look to appoint a successor.
"City Chief Executive Mark Ashton said: “We recognise the huge amount of work that Lee has put in over the last four-and-a-half years to move this club forward and we thank him for all his efforts. There have been some special moments over those years and Lee has played a significant part in them.
“However, success in football is ultimately judged by results and league position and the Board believes that a change of management is needed now for Bristol City.”
"The club will be making no further comment at this stage as we prepare for next Wednesday’s Sky Bet Championship match against Hull City."
Cardiff boss Neil Harris also made changes, giving starts to Will Vaulks and Callum Paterson, while naming three ex-Robins players, Marlon Pack, Aden Flint and Tomlin on the bench.
The visitors had the better of a poor quality first half, getting their front men into the game more than the Robins.
But it was the hosts who launched the first meaningful attack after five minutes when a Nahki Wells header and a follow-up shot from Kalas were blocked.
Nathaniel Mendez-Laing had a 10th-minute shot deflected wide for Cardiff before Zak Vyner's tame header was easily saved by Alex Smithies at the other end.
A Joe Ralls corner in the 21st minute caused havoc in the hosts' goalmouth before the ball was cleared and it was Cardiff looking the more threatening side.
Their best first-half chance fell to Ralls after 37 minutes, but his low shot was blocked.
The same applied to Mendez-Laing's effort on the rebound and when Andreas Weimann gave the ball away, Junior Hoilett also saw his shot ricocheted off a defender.
There was a moment of anxiety for Cardiff at the start of second half when goalkeeper Smithies had his attempted clearance charged down by Wells, but the ball bounced across the goal rather than into it.
Home goalkeeper Bentley had to make the first meaningful save after 53 minutes, tipping a Vaulks shot over the crossbar after good work by Hoilett.
Jay Dasilva's shot was well blocked by Curtis Nelson after a rare Robins raid and it took a fine Smithies save to palm wide a Wells volley.
After both teams had used their first substitute, Johnson made a triple change with 20 minutes left, sending on Afobe, Filip Benkovic and Jack Hunt for Wells, Callum O'Dowda and Vyner.
Benkovic should have put Bristol City ahead with nine minutes left, rising to meet Jamie Paterson's corner but putting his header wide.
Neither side wanted to settle for a point and the game became wide open. After Ward's goal broke the deadlock, the hosts threw even more men forward. There were chances at both ends, but Cardiff held on to clinch a massive third straight away win.
What the manager's said...
Cardiff's Neil Harris: "Danny [Ward] has been excellent for me. He was a wonderful fella, a terrific character and a very good pro. I really like working with him. I do a lot of work with the centre forwards and he is a big part of that.
"We really missed him on Tuesday (against Charlton), not having him as an impact on the bench. I want to continue working with him. He is happy here, he likes it here."
Cardiff are next in action on Tuesday July 7, when they host Blackburn at 7.45pm, while Bristol City face struggling Hull on Wednesday July 8, with kick off coming at 6pm in that fixture.