Portuguese side FC Porto have agreed a deal to sign Real Madrid's veteran goalkeeper Iker Casillas.
The Spain international, who had two years left on his contract at Real, is set to hold a farewell press conference at 10am GMT on 12 July.
The move brings to a close Casillas' 25-year association with the Spanish giants, for whom he made a total of 725 appearances in all competitions.
The La Liga giants confirmed the transfer with a statement on their website and thanked the 34-year-old for his services.
"Real Madrid and FC Porto have reached an agreement for the transfer of Iker Casillas to the Portuguese club. For Real Madrid today is a day, above all, of thanks and recognition," it said.
"One of the best goalkeepers in this club is not just leaving, today the greatest goalkeeper in the history of the club and in the history of Spanish football is moving on to a new stage in his footballing career."
"Our club is 113 years old and Casillas has worn our jersey for 25 of those years. During that time he has become one of our finest leaders and has won the respect, affection, admiration and love of the fans beyond colours and affiliations," the statement read.
Casillas is likely to sign a two-year deal with Porto, with an option to stay for a further year, ESPN reported and Real is likely to pay 50% of his wages.
Casillas, born in the Madrid suburb of Mostoles, joined Real Madrid's academy when he was nine years old, making his first-team debut against Athletic Bilbao in September 1999.
He is the most capped player in the history of the Spanish national team and holds the record for most appearances by a goalkeeper in the Uefa Champions League. His trophy haul includes one World Cup, two European Championships, three Champions Leagues and five La Liga titles.
Casillas' departure clears the way for Real to step up their pursuit of Manchester United's David de Gea, who has been linked with a move to the Spanish capital club.
Meanwhile, Spanish paper Marca reported that United were demanding Sergio Ramos and Keylor Navas in a swap deal for De Gea. The 24-year-old has one year left on his contract and has already turned down a chance to sign a contract extension.
He has already reported for pre-season training at United, but it should be seen whether he will be a part of the squad for their tour to the United States.