Stem cells and their niches constitute units that act cooperatively to achieve adult body homeostasis. How such units form and whether stem cell and niche precursors might be coordinated already during organogenesis are unknown. In fruit flies, primordial germ cells (PGCs), the precursors of germ line stem cells (GSCs), and somatic niche precursors develop within the larval ovary. Together they form the 16-20 GSC units of the adult ovary. We show that ecdysone receptors are required to coordinate the development of niche and GSC precursors. At early third instar, ecdysone receptors repress precocious differentiation of both niches and PGCs. Early repression is required for correct morphogenesis of the ovary and for protecting future GSCs from differentiation. At mid-third instar, ecdysone signaling is required for niche formation. Finally, and concurrent with the initiation of wandering behavior, ecdysone signaling initiates PGC differentiation by allowing the expression of the differentiation gene bag of marbles in PGCs that are not protected by the newly formed niches. All the ovarian functions of ecdysone receptors are mediated through early repression, and late activation, of the ecdysone target gene broad. These results show that, similar to mammals, a brain-gland-gonad axis controls the initiation of oogenesis in insects. They further exemplify how a physiological cue coordinates the formation of a stem cell unit within an organ: it is required for niche establishment and to ensure that precursor cells to adult stem cells remain undifferentiated until the niches can accommodate them. Similar principles might govern the formation of additional stem cell units during organogenesis.