Serotonergic and glutamatergic neurons of the dorsal raphe regulate many brain functions and are important for mental health. Their functional diversity is based on molecularly distinct subtypes; however, the development of this heterogeneity is poorly understood. We show that the ventral neuroepithelium of mouse anterior hindbrain is divided into specific subdomains giving rise to serotonergic neurons as well as other types of neurons and glia. The newly born serotonergic precursors are segregated into distinct subpopulations expressing vesicular glutamate transporter 3 (Vglut3) or serotonin transporter (Sert). These populations differ in their requirements for transcription factors Gata2 and Gata3, which are activated in the post-mitotic precursors. Gata2 operates upstream of Gata3 as a cell fate selector in both populations, whereas Gata3 is important for the differentiation of the Sert + precursors and for the serotonergic identity of the Vglut3 + precursors. Similar to the serotonergic neurons, the Vglut3-expressing glutamatergic neurons, located in the central dorsal raphe, are derived from neural progenitors in the ventral hindbrain and express Pet1. Furthermore, both Gata2 and Gata3 are redundantly required for their differentiation. Our study demonstrates lineage relationships of the dorsal raphe neurons and suggests that functionally significant heterogeneity of these neurons is established early during their differentiation.