The Germany international, 29, has joined the new Spanish and European champions after rejecting Chelsea attempts to extend his contract.
Rudiger moved to Chelsea for an initial fee of £29m from Roma in 2017.
He made 203 appearances and scored 12 goals for the Blues, winning the FA Cup, Champions League, Europa League, Uefa Super Cup and Club World Cup.
Chelsea described Rudiger as “as one of the most passionate characters to represent the club in recent memory”.
Rudiger, who also spoke to Bayern Munich, was offered a contract worth more than £200,000 to stay at Chelsea.
“We gave everything and now we enter a situation where we can’t fight any more because of the sanctions and now Toni will leave,” Chelsea manager Thomas Tuchel said in April.
Tuchel was referring to the restrictions on the club resulting from the UK government’s sanctioning of former owner Roman Abramovich in March, following Russia’s invasion of Ukraine. Abramovich has denied the government’s assertion that he has strong links to Russian President Vladimir Putin.
Abramovich put the club up for sale and a consortium led by American investor Todd Boehly and private equity firm Clearlake Capital completed a £4.25bn takeover in late May.
Chelsea are also set to lose Danish centre-back Andreas Christensen this summer to Barcelona on a free transfer, but captain Cesar Azpilicueta is expected to stay after a one-year extension was triggered in his contract earlier this season.
Real Madrid have said Rudiger will be publicly unveiled to fans on 20 June.