Given the functional importance of gut microbiota in improving host fitness, increasing attention has been paid to the biogeochemical factors that govern the gut microbiota of aquatic animals. By contrast, we know little how and to what extent the gut microbiota are affected by external sources, and particularly internal sources as host ages, though this knowledge is fundamental to sustain a desirable gut microbiota. Here, we begin to assess this question by quantifying the sources of shrimp gut microbiota at the two shrimp lifestages (juvenile and adult). Dominant bacterial phyla were similar, but significantly varied in relative abundance across the shrimp gut, rearing water and sediment. However, the abundance of dominant phyla stayed relatively stable between juvenile and adult stages within a given habitat. The bacterial communities were clustered according to the habitats and stages, of which respectively constrained 22.2% and 5.9% variation in bacterial communities. SourceTracker analysis revealed that sediment facilitated much higher contributions to the source of shrimp gut microbiota than rearing water at both stages. However, when integrating the gut microbiota of juvenile as an internal source, adult gut microbiota was primarily derived from the juvenile shrimp, with a relative contribution of 66.7%. The structural equation modeling further validated this pattern. Our results uncover that a majority of commensals are derived from the younger host, a previously unrecognized source in determining gut microbiota as the shrimp ages.