City defender Nicolas Otamendi is set to go the other way in separate transfer worth €15m.
Dias has made 137 appearances during his four years at Benfica, winning the 2018-19 Portuguese Liga title.
"Ruben is a player we have admired for some time and we have been impressed with how he has progressed at Benfica. He has developed into a real leader and as a defender, he has all the attributes we are looking for," director of football Txiki Begiristain said in City's statement.
"He is strong in the air, good in one-v-one situations and technically he is very good, so we are confident he can thrive in our system."
Dias added: "To have the opportunity to join a club like Manchester City is a fantastic opportunity for me and one I couldn't turn down.
"It is really exciting to be part of such a talented squad and to play for a world class manager like Pep Guardiola, who has a proven track record of developing young players like myself."
Otamendi returns to Portugal after spending four years at Benfica's rivals Porto. He made 210 appearances for City, scoring 11 goals and winning two Premier League titles, one FA Cup and four League Cups.
Dias has 19 Portugal caps and was part of the team that won the UEFA Nations League trophy in 2019, while being awarded man of the match in the final.
The side lost 5-2 to Leicester City on Sunday in what was City's heaviest home defeat since February 2003 and the first time a Guardiola managed team has conceded five goals.
The defeat snapped City's 11-match unbeaten home run in the league dating back to last season, while it was also their first defeat in an opening top-flight home game since a 2-1 loss to Southampton in 1989.