Quantization of the orbital angular momentum of the electron combined with the magnetic moment of the electron suggested that atoms with a magnetic moment should show quantized behavior in a magnetic field. 
In 1922, Otto Stern and Walther Gerlach set out to test this theory. They heated silver in a vacuum tube equipped with a series of narrow aligned slits, creating a molecular beam of silver atoms. They shot this beam through an inhomogeneous magnetic field. Rather than a continuous pattern of Silver atoms, they found two bunches.
Relative to its northern pole, pointing up, down, or somewhere in between, in classical mechanics, a magnet thrown through a magnetic field may be deflected a small or large distance upwards or downwards. The atoms that Stern and Gerlach shot through the magnetic field acted similarly. However, while the magnets could be deflected variable distances, the atoms would always be deflected a constant distance either up or down. This implied that the property of the atom that corresponds to the magnet's orientation must be quantized, taking one of two values (either up or down), as opposed to being chosen freely from any angle.
The choice of the orientation of the magnetic field used in the Stern–Gerlach experiment is arbitrary. In the animation shown here, the field is vertical and so the atoms are deflected either up or down. If the magnet is rotated a quarter turn, the atoms are deflected either left or right. Using a vertical field shows that the spin along the vertical axis is quantized, and using a horizontal field shows that the spin along the horizontal axis is quantized.
The results of the Stern-Gelach experiment caused a sensation, most especially because leading scientists, including Einstein and Paul Ehrenfest argued that the silver atoms should have random orientations in the conditions of the experiment: quantization should not have been observable. At least five years would elapse before this mystery was resolved: quantization was observed but it was not due to orbital angular momentum.
In 1925 Ralph Kronig proposed that electrons behave as if they self-rotate, or "spin", about an axis. Spin would generate a tiny magnetic moment that would split the energy levels responsible for spectral lines, in agreement with existing measurements. Two electrons in the same orbital would occupy distinct quantum states if they "spun" in opposite directions, thus satisfying the exclusion principle. Unfortunately, the theory had two significant flaws: two values computed by Kronig were off by a factor of two. Kronig's senior colleagues discouraged his work and it was never published.
Ten months later, Dutch physicists George Uhlenbeck and Samuel Goudsmit at Leiden University published their theory of electron self rotation. The model, like Kronig's was essentially classical but resulted in a quantum prediction.