The search for alternative therapies to antimicrobial growth promoters (AGP) in poultry production has gained momentum in the past years because of consumer preference and government restrictions on the use of AGP in animal production. Flavonoids are plant-derived metabolites that have been studied for their health-promoting properties that could potentially be used as an alternative to AGP in poultry. In a previous study, we showed that the inclusion of a flavonoid-rich corn cultivar (PennHFD1) in the diet improved the health of broilers undergoing necrotic enteritis. However, the mechanisms of action by which the PennHFD1-based diet ameliorated necrotic enteritis are unknown. This study describes the microbial diversity and composition of the jejunum and ileum of chickens co-infected with Eimeria maxima and Clostridium perfringens and treated with a high-flavonoid corn-based diet. Luminal content and mucosal samples from the jejunum and ileum were collected for DNA extraction, 16S rRNA amplicon sequencing and data analyses. The infection model and the dietary treatments significantly changed the alfa diversity indices (Mucosal samples: ASVs, P = 0.04; Luminal content samples: ASVs, P = 0.03), and beta diversities (Mucosal samples: P < 0.01, Luminal content: P < 0.01) of the ileal samples but not those of the jejunal samples. The microbial composition revealed that birds fed the high-flavonoid corn diet had a lower relative abundance of C. perfringens compared to birds fed the commercial corn diet. The treatments also changed the relative abundance of other bacteria that are related to gut health, such as Lactobacillus. We concluded that both the infection model and the dietary high-flavonoid corn changed the broilers' gut microbial diversity and composition. In addition, the decrease in the relative abundance of C. perfringens corroborates with a decrease in mortality and intestinal lesions due to necrotic enteritis. Collecting different segments and sample types provided a broader understanding of the changes in the gut microbiota among treatments.