Previous studies on the differences in gut microbiota between exclusively breastfed (EBF) and non-EBF infants have provided highly variable results. Here we perform a meta-analysis of seven microbiome studies (1825 stool samples from 684 infants) to compare the gut microbiota of non-EBF and EBF infants across populations. In the first 6 months of life, gut bacterial diversity, microbiota age, relative abundances of Bacteroidetes and Firmicutes, and predicted microbial pathways related to carbohydrate metabolism are consistently higher in non-EBF than in EBF infants, whereas relative abundances of pathways related to lipid metabolism, vitamin metabolism, and detoxification are lower. Variation in predicted microbial pathways associated with non-EBF infants is larger among infants born by Caesarian section than among those vaginally delivered. Longer duration of exclusive breastfeeding is associated with reduced diarrhea-related gut microbiota dysbiosis. Furthermore, differences in gut microbiota between EBF and non-EBF infants persist after 6 months of age. Our findings elucidate some mechanisms of short and long-term benefits of exclusive breastfeeding across different populations.