Environmental conditions, especially diet, affect the diversity of gut microbiota (GM). This diversity within and between populations may influence the host’s health and fitness, therefore plays important roles in adaptation. Regarding this, we collected fecal samples from natural, rural, suburban, and urban habitats to reveal the interaction between diet and compositional and functional diversity of GM of a generalist carnivore, the red fox. The prokaryotic diversity of fecal microbiota was investigated by sequencing the 16S rRNA gene V3-V4 regions. 46 archaeal and bacterial phyla were identified, and Firmicutes was the most common phylum in most samples. The dominant genera in the GM of the red fox were Collinsella, Fusobacterium, Faecalibacterium, Escherichia-Shigella, and Blautia. Fusobacterium was significantly more abundant in suburban (16.0%), natural (11.0%), and rural habitats (10.8%) than in urban habitats (2.0%) indicating dietary differences of the red foxes that feed close to human settlements. However, PICRUSt (Phylogenetic Investigation of Communities by Reconstruction of Unobserved States) showed that the host’s habitat did not significantly affect the functional diversity. Our study determined the compositional changes of the GM of a wild animal for the first time in the Anatolian peninsula and revealed the effects of dietary changes, especially urbanization, on the diversity of GM of red foxes.