This is the explanation I was given several decades ago when I was spotty PhD student - actually it might have been Neville Mott himself who gave the lectures as I think he was still active in the early 80s. I was actually working on silver-germanium selenide contacts, but the effect is common to all metal-semiconductor contacts including Schottky diodes. If you feel the urge to follow up this answer by asking me deep and searching questions note that (a) this was thirty years ago and (b) I'm not sure I ever grasped exactly why interfacial states would pin the band gap.
Anyhow, if you look at the band structure of metal and the semiconductor separately, i.e. not in contact, they look something like:
It doesn't matter exactly where the Fermi level lies wrt to semiconductor band gap, though in every picture I've see it's drawn near the top of the gap. The argument is that when you contact the metal and semiconductor this creates states at the interface that lie in the band gap, and these interfacial states pin the middle of the band gap to the Fermi energy of the metal. The bands in the semiconductor curve to accomdate this:
and the result is that there is an energy step, $\Phi$, between the metal and semiconductor. So electrons from the semiconductor flow into the metal creating a depletion zone in the semi conductor. This behaves like a PN diode where the metal is analogous to the P side. Electrons flow freely from the semiconductor to the metal, but it's difficult for electrons to flow from the metal to the semiconductor because they need enough energy to jump the energy step, $\Phi$.