Manchester City have completed the signing of Real Madrid’s Danilo on a five-year contract for a fee of £26.5m after the two clubs reached an agreement over the transfer of the Brazilian defender in midweek.

The 26-year-old will join his new team-mates on their tour of the United States after agreeing personal terms and passing his medical at the Premier League club. Pep Guardiola views Danilo as a versatile player, who can operate at left-back and in defensive midfield, as well as at right-back.

His arrival means City have now spent almost £150m this summer following the transfers of Kyle Walker, Bernardo Silva and the goalkeeper Ederson.

“I am very, very happy to be joining Manchester City,” Danilo said. “There has been strong interest from other clubs, but it has always been my ambition to play for Pep Guardiola. As soon as I heard of his interest, I knew immediately I wanted to be a City player.”

Guardiola was always likely to target the full-back positions after releasing Gaël Clichy, Pablo Zabaleta and Bacary Sagna at the end of last season. City have already signed Walker for £50m plus add-ons, while they are set to sign Monaco’s Benjamin Mendy for £52m, a world-record fee for a defender.

Guardiola and City had reached an agreement in principle to sign Dani Alves after he left Juventus but the former Barcelona player opted to join Paris Saint-Germain. The French club had offered the Brazilian almost twice as much in wages.

Danilo joined Real Madrid from Porto in 2015 and has 15 caps for Brazil, having made his international debut in 2011. He started 17 matches for Real in La Liga last season. Danilo could come up against his former side next week as City take on Real in Los Angeles in Wednesday’s pre-season match.