The Spain international, 32, won the Liga title three times and the Champions League twice in his eight-year career at the Santiago Bernabeu.
The last Spanish title triumph arrived last season on the final day when they beat Mallorca 3-1.
The player had asked Madrid, who were not keen on strengthening one of their major domestic rivals, to facilitate a transfer out of recognition of his contribution to their success.
Meanwhile Mallorca have signed Che defender David Navarro, who cannot play until September after he punched Internazionale's Nicolas Burdisso on the nose following a Champions League quarter-final last season.
Elsewhere in Spain, Zaragoza are reportedly in negotiations with Atletico Madrid for Pablo Ibanez while Arsenal's Mexican prodigy Carlos Vela has joined Osasuna on a season loan.