Objective Weaning is an important stage in the life of young mammals, which is associated with intestinal inflammation, gut microbiota disorders, and even death. β-Carotene displays anti-inflammatory and antioxidant activities, which can prevent the development of inflammatory diseases. However, whether β-carotene can affect intestinal microbiota remains unclear. Methods Twenty-four piglets were distributed into four groups: the normal suckling group (Con), the weaning group (WG), the weaning+β-carotene (40 mg/kg) group (LCBC), and the weaning+β-carotene (80 mg/kg) group (HCBC). The serum, jejunum, colon, and faeces were collected separately from each group. The effects of β-carotene on the phenotype, overall structure, and composition of gut microbiota were assessed in weaning piglets. Results The results showed that β-carotene improved the growth performance, intestinal morphology and relieved inflammation. Furthermore, β-carotene significantly decreased the species from phyla Bacteroidetes and the genus Prevotella, and Blautia, and increased the species from the phyla Firmicutes and the genera p-75-a5, and Parabacteroides compared to the WG group. Spearman's correlation analysis showed that Prevotella and Blautia were positively correlated, and Parabacteroides and Synergistes were negatively correlated with the levels of interleukin-1β (IL-1β), IL-6, and tumour necrosis factor-α (TNF-α), while p-75-a5 showed negative correlation with IL-6 in serum samples from piglets. Conclusion These findings indicate that β-carotene could alleviate weaning-induced intestinal inflammation by modulating gut microbiota in piglets. Prevotella may be a potential target of β-carotene in alleviating the weaning-induced intestinal inflammation in piglets.