Aging is associated with a decline in sex hormones, variable between sexes, that has an impact on many different body systems and might contribute to age-related disease progression. We aimed to characterize the sex differences in gut microbiota, and to explore the impact of depletion of gonadal hormones, alone or combined with postnatal overfeeding, in rats. Many of the differences in the gut microbiota between sexes persisted after gonadectomy, but removal of gonadal hormones shaped several gut microbiota features towards a more deleterious profile, the effect being greater in females than in males, mainly when animals were concurrently overfed. Moreover, we identified several intestinal miRNAs as potential mediators of the impact of changes in gut microbiota on host organism physiology. Our study points out that gonadal hormones contribute to defining sex-dependent differences of gut microbiota, and discloses a potential role of gonadal hormones in shaping gut microbiota, as consequence of the interaction between sex and nutrition. Our data suggest that the changes in gut microbiota, observed in conditions of sex hormone decline, as those caused by ageing in men and menopause in women, might exert different effects on the host organism, which are putatively mediated by gut microbiota-intestinal miRNA cross-talk.