Interactions between stem cells and their surrounding microenvironment, or niche, are critical for the establishment and maintenance of stem-cell properties. The adult Drosophila testis contains a morphologically discrete stem-cell niche, the 'hub'. The small cluster of non-dividing, somatic hub cells at the anterior tip of the fly testis is contacted by the germline stem cells (GSCs), which retain their stem-cell character through the direct association with the hub. Here we show that integrin-mediated adhesion is important for maintaining the correct position of embryonic hub cells during gonad morphogenesis. The misplaced hub in integrin-deficient embryos directs the orientation of cell divisions in the presumptive GSCs, a hallmark of the active germline stem-cell niche. A decrease in integrin-mediated adhesion in adult testes, which resulted in a loss of the hub and the stem-cell population, revealed the importance of hub-cell anchoring. Finally, we show that an extracellular matrix (ECM) is present around the gonad during late embryogenesis and that this ECM is defective in integrin-deficient gonads. On the basis of our data, we propose that integrins are required for the attachment of the hub cells to the ECM, which is essential for maintaining the stem-cell niche.