The objective of this study was to evaluate the effects of protein restriction and subsequent protein realimentation on the body composition, gut microbiota and metabolite profiles of piglets. Fifty weaned piglets were randomly assigned to two treatments: a normal protein (NP) group (20% crude protein (CP)) or a low protein (LP) group (16% CP) with five animals per pen and five pens per group. Treatment diets were fed for 14 d during the protein restriction phase, and then all pigs were fed the same nursery diets with a normal CP level (19% CP) during the protein realimentation phase until they reached an average target body weight (BW) of 25 ± 0.15 kg. At day 14 and the end of the experiment, one piglet close to the average BW of each pen was slaughtered to determine body composition, microbial composition and microbial metabolites. Results showed that there was no difference (p > 0.05) in the experimental days to reach target BW between the LP and NP groups. The average daily gain (ADG) and gain:feed ratio (G:F) during the protein restriction phase as well as BW at day 14, were significantly decreased (p < 0.05) in the LP group compared with the NP group. However, there were no significant differences (p > 0.05) during the protein realimentation phase and the overall experiment. Similarly, piglets in the LP group showed a significantly decreased body protein content (p < 0.05) at day 14, but not (p > 0.05) at the end of the experiment. The relative abundance of Parabacteroides, Butyricicoccus, Olsenella, Succinivibrio and Pseudoramibacter were significantly increased (p < 0.05), while the relative abundance of Alloprevotella and Faecalicoccus were significantly decreased (p < 0.05) in the LP group at day 14. At the end of the experiment, the piglets in the LP group showed a higher (p < 0.05) colonic relative abundances of Parabacteroides, unidentified Christensenellaceae and Caproiciproducens, and a lower (p < 0.05) relative abundance of unidentified Prevotellaceae, Haemophilus, Marvinbryantia, Faecalibaculum, Neisseria and Dubosiella than those in the NP group. Metabolomics analyses indicated that tryptophan metabolism and vitamin metabolism were enriched in the LP group at day 14, and glycerophospholipid metabolism and fatty acid esters of hydroxy fatty acid metabolism were enriched at the end of the experiment. Moreover, Spearman’s correlation analysis demonstrated that the microbial composition was highly correlated with changes in colonic metabolites. Collectively, these results indicated that protein restriction and subsequent realimentation lead to compensatory growth and compensatory protein deposition in piglets and contribute to animal intestinal health by altering the gut microbiota and its metabolites.