Centre-back Aden Flint headed a 66th-minute winner to give Bristol City a 2-1 victory over Cardiff in a thrilling Severnside derby at Ashton Gate.
The hosts took a 20th-minute lead when Joe Bryan fed Callum O'Dowda on the right side of the box and the Republic of Ireland winger cut inside onto his left foot to find the far corner with a brilliant finish. But Cardiff replied four minutes before the break when Junior Hoilett got the better of Hordur Magnusson on the byline and crossed for Omar Bogle to fire home through the legs of goalkeeper Frank Fielding.
The visitors were reduced to 10 men on 55 minutes when Bogle was shown a red card by referee Mike Jones for a late challenge on Marlon Pack in the centre of the pitch. Seven minutes later a long throw from the right by Magnusson was met by an unstoppable Flint header to put Bristol back in front and confirm them as genuine candidates for automatic promotion this season.
Bogle after scoring
Cardiff had to make an early change when Nathaniel Mendez-Laing went down injured on seven minutes before being replaced by Liam Feeney.
O'Dowda's goal was his first in the Sky Bet Championship for the Robins and soon his free-kick from the right set up Milan Djuric for a near-post flick that brought a save from Neil Etheridge.
Bryan had a fierce volley saved by Etheridge before both teams had opportunities to score from free-kicks on the edge of the box. First, Hoilett saw his shot deflected over by the Bristol wall after a foul by Pack. Then Magnusson fired into the Cardiff wall following a trip by Bruno Manga on Bobby Reid. Bogle had a chance to equalise shortly before his goal, but shot straight at Fielding.
Home supporters were incensed by Bogle's mistimed challenge on Pack that brought his dismissal and moments after Neil Warnock had replaced Feeney with Danny Ward, there was more anger as Craig Bryson picked up a yellow card for a late tackle on Bryan.
Bristol were fired up by their man advantage and a brilliant mazy dribble into the box by Reid ended with a low drive saved by Etheridge. To their credit, Cardiff remained a threat on the break, but were lucky not to fall further behind on 85 minutes when Josh Brownhill's swerving shot clipped a post.
Lee Tomlin, signed from Bristol City during the summer, had a couple of opportunities to test his old club with free-kicks from dangerous positions in the closing minutes, but Lee Johnson's men held firm for three hugely important points.
Bristol City: Fielding, Smith, Flint, Baker, Magnusson O'Dowda, Brownhill, Pack (Taylor 66), Bryan, Djuric, Reid (Woodrow 81).
Cardiff: Etheridge, Paterson, Morrison, Manga, Bamba, Peltier, Mendez-Laing (Feeney 6; sub Ward 56), Bryson (Tomlin 83), Ralls, Hoilett, Bogle.
Referee: Michael Jones (Chester)