Endometriosis (EMS) is a chronic disease that can cause dysmenorrhea, chronic pelvic pain, and infertility, among other symptoms. EMS diagnosis is often delayed compared to other chronic diseases, and there are currently no accurate, easily accessible, and non-invasive diagnostic tools. Therefore, it is important to elucidate the mechanism of EMS and explore potential biomarkers and diagnostic tools for its accurate diagnosis and treatment. In the present study, we comprehensively analyzed the differential expression, immune infiltration, and interactions of EMS-related genes in three Homo sapiens datasets. Our results identified 332 differentially expressed genes (DEGs) associated with EMS. Gene ontology analysis showed that these changes mainly focused on the positive regulation of endometrial cell proliferation, cell metabolism, and extracellular space, and EMS involved the integrin, complement activation, folic acid metabolism, interleukin, and lipid signaling pathways. The LASSO regression model was established using immune DEGs with an area under the curve of 0.783 for the internal dataset and 0.656 for the external dataset. Five genes with diagnostic value, ACKR1, LMNB1, MFAP4, NMU, and SEMA3C, were screened from M1 and M2 macrophages, activated mast cells, neutrophils, natural killer cells, follicular T helper cells, CD8+, and CD4+ cells. A protein−protein interaction network based on the immune DEGs was constructed, and ten hub genes with the highest scores were identified. Our results may provide a framework for the development of pathological molecular networks in EMS.