The defender, 20, who made 144 appearances for the Rams having come through the club's youth ranks, will complete his switch to Ashton Gate following a medical on Wednesday.
Rams manager Nigel Clough said: "Lewin is a terrific lad and a good
professional and I'm sure he will do well at Bristol City.
"We are looking to make changes to the squad and by allowing Lewin to move it gives us more flexibility with re-shaping our defensive positions.
"On behalf of everyone at Derby County we wish Lewin all the best
for the future."