Brownhill made only six appearances for North End last season, but scored three goals in 27 games on loan at League One play-off winners Barnsley.
The 20-year-old rejected a new contract offer from Preston, who will be owed compensation for the move.
"As well as being a good footballer he's also a fantastic character," said City head coach Lee Johnson.
"He is a young, hungry, sought-after player who is experienced beyond his years in modern day football, and we've beaten off competition from other clubs to get him."
Find all the latest football transfers on our dedicated page.
Bristol City will sign midfielder Josh Brownhill from Preston at the end of his current contract on 30 June.