Schalke’s Germany midfielder Leon Goretzka has agreed to join Bayern Munich in the summer.

The 22-year-old has been Schalke’s leading player but has signed a four-year contract with Bayern to take effect from July 1, the Bundesliga champions announced.

Goretzka, who had been a reported target for several Premier League sides, passed a medical on Thursday.

“We are very happy that Leon Goretzka, a German international with great potential, has opted for Bayern, despite considerable competition from abroad,” Bayern chief executive Karl-Heinz Rummenigge said on the club website.

“This ensures that Leon Goretzka will remain in the Bundesliga.”

Goretzka, joined the Royal Blues from Bochum in 2013 and has gone on to win 12 caps for the national team.

Schalke sporting director Christian Heidel admitted the club had had to admit defeat in the battle to keep hold of their prized asset.

“Leon Goretzka informed us earlier this week that he wishes to leave the club and join Bayern,” Heidel said at a press conference.

“We were very sorry to hear this. Karl-Heinz Rummenigge told us yesterday that Leon has completed a medical. We are losing a very, very good player.

“We did everything we could to try and keep him. In the summer he and his agent reached an agreement, but he wanted time to develop.

“We can cope with this situation, it wasn’t a complete surprise. We are prepared for this.”

Schalke coach Domenico Tedesco said, according to the club’s Twitter page, that the team were “sad and disappointed to be losing Leon, both as a player and as a person”.

Schalke lie third in the Bundesliga table, 14 points behind leaders Bayern, ahead of Sunday’s meeting with Hannover.

The impending arrival of Goretzka at Bayern will increase speculation over the future of Arturo Vidal, who has been linked with a move away from the Allianz Arena.