The fan and rays of the C. elegans male tail constitute a compound sensory organ essential for mating. Within this organ, the individual sensilla, known as rays, have unique identities. We show that ray identities are patterned by a selector gene mechanism in a manner similar to other serially homologous axial structures. One selector gene that promotes the identities of a subset of the rays is the Hox gene egl-5. Within EGL-5-expressing rays, further patterning is provided by a Pax-6 homolog and a signal of the TGFβ family. These genes and pathway coordinately specify multiple ray properties affecting all three terminal ray cell types. These properties include complex patterns of FMRFamide-like (FaRP) neuropeptides, serotonin (5HT) and dopamine expression, and ray morphology. Differences in these differentiated characteristics give each sensillum a unique identity and potentially endow the compound ray organ with a higher-order information gathering capacity.