The red imported fire ant (Solenopsis invicta Buren, 1972) is a globally significant invasive species, causing extensive agricultural, human health, and biodiversity damage amounting to billions of dollars worldwide. The pathogenic fungus Metarhizium anisopliae (Metchnikoff) Sorokin (1883), widely distributed in natural environments, has been used to control S. invicta populations. However, the interaction between M. anisopliae and the immune system of the social insect S. invicta remains poorly understood. In this study, we employed RNA-seq to investigate the effects of M. anisopliae on the immune systems of S. invicta at different time points (0, 6, 24, and 48 h). A total of 1313 differentially expressed genes (DEGs) were identified and classified into 12 expression profiles using short time-series expression miner (STEM) for analysis. Weighted gene co-expression network analysis (WGCNA) was employed to partition all genes into 21 gene modules. Upon analyzing the statistically significant WGCNA model and conducting Kyoto Encyclopedia of Genes and Genomes (KEGG) pathway enrichment analysis on the modules, we identified key immune pathways, including the Toll and Imd signaling pathways, lysosomes, autophagy, and phagosomes, which may collectively contribute to S. invicta defense against M. anisopliae infection. Subsequently, we conducted a comprehensive scan of all differentially expressed genes and identified 33 immune-related genes, encompassing various aspects such as recognition, signal transduction, and effector gene expression. Furthermore, by integrating the significant gene modules derived from the WGCNA analysis, we constructed illustrative pathway diagrams depicting the Toll and Imd signaling pathways. Overall, our research findings demonstrated that M. anisopliae suppressed the immune response of S. invicta during the early stages while stimulating its immune response at later stages, making it a potential biopesticide for controlling S. invicta populations. These discoveries lay the foundation for further understanding the immune mechanisms of S. invicta and the molecular mechanisms underlying its response to M. anisopliae.