FC Porto defender Pepe will play for AC Milan for five years.
The deal is worth EUR30 million (US$41 million), the Portuguese champions said on the Lisbon Stock Exchange.
The 24-year-old Pepe is the second center back brought to the Santiago Bernabeu stadium, after Germany defender Christoph Metzelder arrived from Borussia Dortmund on Sunday.
The transfer is still dependent on Pepe passing a medical.
Pepe joined Porto in 2004 after four seasons at Madeira Island club Maritimo.
He is the second Brazilian player sold by Porto this summer, with midfielder Anderson leaving for Old Trafford for an undisclosed sum.
"We should use shock therapy to sober up the Americans. In this case, the Americans will speak about the need to resume dialogue. There is no other option"
The United States is concerned about the current crisis in the relations with Russia and suggests returning to reasonable policies to avoid a nuclear war