Alzheimer's disease (AD) is a neurodegenerative disorder with a higher risk incidence in females than in males, and there are also differences in AD pathophysiology between sexes. The role of sex in the pathogenesis of AD may be crucial, yet the cellular and molecular basis remains unclear. Here, we performed a comprehensive analysis using four public transcriptome datasets of AD patients and age-matched control individuals in prefrontal cortex, including bulk transcriptome (295 females and 402 males) and single-nucleus RNA sequencing (snRNA-seq) data (224 females and 219 males). We found that the transcriptomic profile in female control was similar to those in AD. To characterize the key features associated with both the pathogenesis of AD and sex difference, we identified a co-expressed gene module that positively correlated with AD, sex, and aging, and was also enriched with immune-associated pathways. Using snRNA-seq datasets, we found that microglia (MG), a resident immune cell in the brain, demonstrated substantial differences in several aspects between sexes, such as an elevated proportion of activated MG, altered transcriptomic profile and cell-cell interaction between MG and other brain cell types in female control. Additionally, genes upregulated in female MG, such as TLR2, MERTK, SPP1, SLA, ACSL1, and FKBP5, had high confidence to be identified as biomarkers to distinguish AD status, and these genes also interacted with some approved drugs for treatment of AD. These findings underscore the altered immune response in female is associated with sex difference in susceptibility to AD, and the necessity of considering sex factors when developing AD biomarkers and therapeutic strategies, providing a scientific basis for further in-depth studies on sex differences in AD.