Fibromyalgia (FM) is a chronic nonarticular rheumatic disease mainly characterized by diffuse disseminated skeletal muscle pain, with varied symptoms including anxiety, sleep disturbance, and fatigue. Due to its unknown etiology and pathogenesis, FM is easily ignored in clinical practice, resulting in unclear diagnosis and difficult treatment. This study is aimed at investigating whether AKAP12 and RNF11 can be used as biomarkers for the diagnosis of FM and at determining their correlation with immune infiltration. The FM dataset in Gene Expression Omnibus (GEO) database was downloaded and was randomly divided into the training and test sets. Differentially expressed genes (DEGs) were screened, and functional correlation analysis was performed. Diagnostic markers of FM were screened and validated by random forest (RF). The least absolute shrinkage and selection operator (LASSO) logistic regression algorithm was then used to evaluate immune cell infiltration in the FM patients' peripheral blood. Finally, Spearman's rank correlation analysis was used to identify correlation between the diagnostic indexes and immune cell infiltration. A total of 69 DEGs were selected. Results indicated that AKAP12 and RNF11 can be used as diagnostic markers of FM, and CD8 + T cells might contribute in the pathogenesis of FM. In addition, AKAP12 was positively correlated with CD8 + T cells, while RNF11 was negatively correlated with CD8 + T cells. In conclusion, AKAP12 and RNF11 can be used as diagnostic indicators of FM, and CD8 + T cells may be involved in the occurrence and development of FM.