Brazil coach Tite opted to pick Danilo ahead of Alex Sandro for Tuesday's Superclasico in Jeddah, as first-choice right-back Dani Alves continues his recovery from a serious knee injury.
But less than 10 minutes into the second half of the game, Danilo saw his evening come to a premature end.
Tracking back in order to stop a dangerous incursion from Argentina striker Mauro Icardi, the City man went over heavily on his ankle as he conceded a corner.
Danilo received brief treatment on the pitch before Tite ordered the substitution, with the defender in visible pain.
Juventus' Alex Sandro was called in, while Danilo was able to limp off the pitch unaided.
Instead of retiring from the stadium, the defender stayed on the bench with his team-mates, applying ice to the injured ankle.
City will now be hoping that their full-back has avoided serious damage to the joint, with a sprain likely to rule the Brazilian out for at least a couple of weeks.