Liverpool boss Jurgen Klopp had been hoping to persuade the Germany international to move to Anfield.
A number of other clubs, including Barcelona and Juventus, had also been interested in the 22-year-old.
But Goretzka has elected to remain in the Bundesliga, with Schalke’s general manager Christian Heidel confirming he has rejected a deal to stay at the Veltins Arena, and has inked a pre-contract agreement with Die Roten.
"Leon informed us earlier in the week that he might leave the club and join Bayern,” said Heidel on Friday morning.
“Yesterday, Karl-Heinz Rummenigge (Bayern CEO) informed us that Leon has passed the medical check.