Pawel Abbott grabbed a late winner for Huddersfield in a match marred by an ugly incident which saw Town boss Peter Jackson sent to the stands.
Jackson was banished from the touchline after grabbing Robins substitute Lee Johnson's throat, sparking a mass brawl involving both sets of players.
Bristol City had taken the lead when Phil Jevons pounced on a rebound.
Luke Beckett levelled after a flowing move, but Abbott won it in stoppage time by forcing home a corner.