Granular materials segregate according to grain size when exposed to periodic perturbations such as vibrations . Moreover, mixtures of grains of different sizes can also spontaneously segregate in the absence of external perturbations: when such a mixture is simply poured onto a pile, the large grains are more likely to be found near the base, while the small grains are more likely to be near the top. Here we report another size-separation effect, which arises when we pour a granular mixture between two vertical plates: the mixture spontaneously stratifies into alternating layers of small and large grains whenever the large grains have larger angle of repose than the small grains. We find only spontaneous segregation, without stratification, when the large grains have smaller angle of repose than the small grains. The stratification is related to the occurrence of avalanches: during each avalanche, the grains separate into a pair of static layers, with the small grains forming a sublayer underneath the layer of large grains.