The fall armyworm (Spodoptera frugiperda, J.E. Smith) is one of the most important agricultural pests in the world and causes serious damage to many significant crops. Insect gut microbiota plays a vital role in host immunity, digestion, and development, helping the higher organism colonize in a new environment. However, the effects of different diets on midgut microbial composition and host immunity in S. frugiperda remain unclear. So far, no reports have compared the gut microbiota of fall armyworm reared using an artificial diet compared to corn leaf in Guangzhou, China. High-throughput 16S rRNA sequencing technology was applied to gain insight into the composition of the gut microbiota of S. frugiperda feeding on corn leaf (field diet) and on a starch-rich artificial diet (lab diet). The fall armyworm gut microbiota was dominated by the bacterial phyla Firmicutes and Proteobacteria. Despite the difference in diet, the core bacterial community was represented by the genus Enterococcus. However, the bacterial community is dominated by a few phylotypes, namely operational taxonomical units 1 (OTU1) (Enterococcus casseliflavus), OTU3 (Enterobacteriaceae), OTU2 (Weissella), and OTU4 (Clostridium), accounting for 97.43% of the total OTUs in the complete dataset. A significant difference was identified in the bacterial communities between the “lab diet” and the “field diet” groups. OTU1 and OTU2 were significantly higher in the “field diet” group, whereas OTU3 and OTU4 were higher in the “lab diet” group. A phylogenetic investigation of the communities by reconstruction of unobserved states (PICRUSt) predicted functional analysis indicates the presence of several genes associated with plant biomass degradation. Importantly, antibiotic-mediated perturbation of the midgut microbial community significantly impacts the expression profile of the important immune genes of the host. Furthermore, the oral reintroduction of gut bacterial isolates (E. mundtii and E. gallinarum) significantly enhances host resistance to AcMNPV infection. Taken together, our results indicate that diet composition is an important driver in shaping insect gut microbiome and immune gene expression, ultimately playing an important role in the pest defense system.