Lee Johnson's side found themselves on the back foot for long spells in the Welsh capital but the Robins captain scored a decisive goal from 25 yards to send his side into the Championship play-off places.
The defeat meant it was more derby-day woe for Neil Warnock two weeks on from Cardiff's loss at the hands of rivals Swansea.
Their miserable run of one victory from their last six matches leaves them in 14th place, seven points adrift of the top six.
Joe Ralls played through the pain of a groin injury to net a hat-trick against Birmingham last weekend.
But this game proved too much for the midfielder who was replaced by former Robins playmaker Lee Tomlin.
Cardiff goalkeeper Neil Etheridge almost gifted the visitors an early goal with a wayward clearance that went straight to Brownhill.
Warnock's men grew in confidence after their early scare and thought their pressure should have resulted in a penalty when Baker tugged at Flint's shirt as he tried to meet Pack's corner.
While many were still protesting, Junior Hoilett picked the ball up 25 yards from goal and rattled the crossbar with a fierce curling shot.
Bogle was the next Cardiff player to be denied by a last ditch Baker block, but just as Cardiff were turning the screw, Brownhill's bolt from the blue turned the game on its head.
He took a touch and sent a dipping strike over Etheridge and into the back of the net for a 1-0 lead after 67 minutes.
Substitute Gary Madine had a chance to level with his first touch after rising to meet Pack's corner, but Bentley grasped the ball with both hands as Bristol City secured bragging rights.