The 32-year-old will be re-united with Jose Mourinho, who has managed his compatriot during spells at Chelsea and Porto.
Carvalho flew in to Madrid last night before passing a medical this morning in the Spanish capital.
The Portuguese was then presented to the Spanish media after signing a two-year contract.
He said: "I've wanted to come here for a long time.
"Mourinho is a winning manager and I have come to a winning club."
Carvalho becomes the fifth summer signing at the Spanish club with Sami Khedira, Pedro Leon, Angel di Maria and Sergio Canales all linking up with Mourinho as he looks to wrestle the Spanish title from bitter rivals Barcelona in his first season in charge.