Manuel Neuer will play for Bayern Munich from next season after a fee was agreed with Schalke.
Neuer was moving into the last year of his contract with Schalke and was certain to move on. He had been linked with Manchester United but the goalkeeper always made it clear he wanted to remain in Germany.
He will officially sign a five-year contract with the Bavarians once he undergoes a medical upon his return from international duty, and become a Bayern player on July 1.
Neuer said: "I am really looking forward to this huge and exciting challenge at Bayern.
"Many of my international team-mates will be my team-mates in Munich. Therefore I won't be going into a new environment and will certainly settle in quickly.''
Bayern chief executive Karl-Heinz Rummenigge said: "Bayern are very happy in Manuel Neuer to have signed for the long term not only the Germany number one, but also one of the best goalkeepers in the world.''
Neuer has been Schalke's number one since making his debut in 2005, and made his farewell appearance in their DFB-Pokal final victory earlier this month.
Schalke general manager and board member Horst Heldt said the club had allowed Neuer to leave with a heavy heart: "This was a difficult decision for all those involved, because in Manuel Neuer the club are losing an outstanding player in every respect.
"But we have now finally decided to accept Bayern's offer, because given the circumstances it is the best solution for Schalke. We also promised Manuel we would honour his wish to be able to move on in the summer. Even though it will certainly hurt almost all Schalke supporters to the soul to lose such a role model, we should not forget the great things Manuel Neuer has achieved at the club.
"In sporting terms, he had a huge role in the success of the last five years, this season in winning the DFB-Pokal and in reaching the Champions League semi-finals for the first time.''
Bayern have also confirmed the signing of one of Neuer's former Schalke team-mates, Brazilian right-back Rafinha, from Genoa. The 25-year-old, who spent five years in Gelsenkirchen before moving to Serie A last year, has signed a three-year contract at Bayern.
Ralf Fahrmann will be Neuer's replacement at Schalke after he rejoined the club at which he started his career on a free transfer from Eintracht Frankfurt. The 22-year-old has joined on a four-year contract.