Schalke 04 confirmed Friday that Germany midfielder Leon Goretzka will join Bayern Munich for next season on a free transfer, with the Bundesliga leaders beating Liverpool to his signature.
"Leon Goretzka informed us at the start of the week that he wants to leave the club and will join FC Bayern," said Schalke sporting director Christian Heidel.
"We did everything to keep Leon at Schalke."
The 22-year-old completed a medical in Munich on Thursday and has signed a contract until June 30, 2022, Bayern later revealed on their website.
"We are very happy that Leon Goretzka has decided to join Bayern, despite considerable competition from abroad," said Bayern chairman Karl-Heinz Rummenigge after Barcelona and Juventus were also linked to Goretzka.
"This ensures that Leon Goretzka remains in the Bundesliga."
The midfielder has vowed to help Schalke finish in the top four this season, to earn a Champions League place, and to lift German Cup as his parting gift.
"I know it will disappoint everyone, but anyone who knows me, just a little bit, knows I will give my all, as usual," he said.
"I want to lead Schalke back into the Champions League and win the German Cup in Berlin on May 19.
"The five years at Schalke will stay firmly in my heart and mind."
Goretzka, 22, has scored six goals in 12 appearances for his country.
He made his breakthrough at the 2017 Confederations Cup, where he helped a Germany side missing their World Cup-winning stars beat Chile 1-0 in the final.
The right-footed Goretzka joined Schalke from VfL Bochum in 2013 and has scored 19 goals in 130 games for the Royal Blues.
He can play as a deep-lying midfielder, winger or attacking midfielder and his versatility will be a bonus for Bayern, whose head coach Jupp Heynckes welcomed the move.
"He has developed really well, is intelligent and performance-oriented, he can bring a new impulse," said Heynckes in Munich.