Background: Magnesium is a mineral that modulates several physiological processes. However, its relationship with intestinal microbiota has been scarcely studied. Therefore, this study aimed to assess the role of dietary magnesium content to modulate the intestinal microbiota of Wistar male rats. Methods: Rats were randomly assigned one of three diets: a control diet (C-Mg; 1000 mg/kg), a low magnesium content diet (L-Mg; 60 mg/kg), and a high magnesium content diet (H-Mg; 6000 mg/kg), for two weeks. After treatment, fecal samples were collected. Microbiota composition was assessed by sequencing the V3–V4 hypervariable region. Results: The C-Mg and L-Mg groups had more diversity than H-Mg group. CF231, SMB53, Dorea, Lactobacillus and Turibacter were enriched in the L-Mg group. In contrast, the phyla Proteobacteria, Parabacteroides, Butyricimonas, and Victivallis were overrepresented in the H-Mg group. PICRUSt analysis indicated that fecal microbiota of the L-Mg group were encoded with an increased abundance of metabolic pathways involving carbohydrate metabolism and butanoate metabolism. Conclusion: Dietary magnesium supplementation can result in intestinal dysbiosis development in a situation where there is no magnesium deficiency. Conversely, low dietary magnesium consumption is associated with microbiota with a higher capacity to harvest energy from the diet.