Animal development entails the organization of specific cell types in space and time, and spatial patterns must form in a robust manner. In the zebrafish spinal cord, neural progenitors form stereotypic patterns despite noisy morphogen signaling and large-scale cellular rearrangements during morphogenesis and growth. By directly measuring adhesion forces and preferences for three types of endogenous neural progenitors, we provide evidence for the differential adhesion model in which differences in intercellular adhesion mediate cell sorting. Cell type-specific combinatorial expression of different classes of cadherins (N-cadherin, cadherin 11, and protocadherin 19) results in homotypic preference ex vivo and patterning robustness in vivo. Furthermore, the differential adhesion code is regulated by the sonic hedgehog morphogen gradient. We propose that robust patterning during tissue morphogenesis results from interplay between adhesion-based self-organization and morphogen-directed patterning.