The Brazilian centre-back joins after Los Blancos meet the 50-million euro buyout clause in his contract with the Portuguese club.
"Real Madrid C.F. and FC Porto have reached an agreement on the transfer of Eder Militao," read the club statement "He will stay at the club for the next six seasons until 30 June 2025.
"MARCA reported that an agreement had been made between Real Madrid, Porto and the player while a payment to Militao's former club Sao Paulo was yet to be finalised.