Luiz, 21, joined City from Vasco da Gama in 2017, but never played a game for the Premier League champions.
He spent the past two seasons on loan at Girona, making 46 appearances for the Spanish side.
His request for a work permit at City was rejected last August and he rejoined Girona for the 2018-19 season.
Villa says his transfer to the club is also subject to a work permit and it takes the spending for their Premier League return to more than £100m.
“Douglas is an extremely talented young player with an outstanding pedigree who I am sure will fit nicely into our style and system of play,” said Villa boss Dean Smith.
Luiz was player of the tournament at the Toulon Tournament in June as Brazil Under-21s won the competition.
Find all the latest football transfers on our dedicated page.