Patients with anal condyloma acuminatum (CA) are at risk of developing anal cancer which is associated with oncogenic human papillomavirus (HPV) infection. Investigation of anal HPV prevalence and risk factors can provide effective strategies for the prevention of anal cancer. A retrospective study was conducted among 549 patients with anal CA in the Third People's Hospital of Shenzhen between January 2019 and October 2021. HPV prevalence and HIV antibodies were detected by fluorescent PCR and ELISA, respectively. Logistic regression model and structural equation modeling (SEM) were conducted to analyzed the risk factors of oncogenic HPV infection. The overall prevalence of HPV was 96.72%. Both HPV6 (N = 285, 51.91%) and HPV11 (N = 300, 54.64%) were more than half infected and the most frequent Hr‐HPV genotype was HPV16 (N = 138, 25.14%). HIV‐positive (AOR: 5.02, 95% CI: 2.98−8.60, p < 0.0001) and history of syphilis (AOR: 4.24, 95% CI: 2.31−8.46, p < 0.0001) were independent risk factors statistically associated with oncogenic HPV infection. Ever had anal sex (AOR: 3.40, 95% CI: 1.28−11.81, p = 0.0267) and age 35 years and older (AOR: 2.79, 95% CI: 1.53−5.15, p = 0.0009) were associated with HPV16 and HPV52, respectively. SEM analyses showed that HIV‐positive (b = 1.549, p < 0.001) and history of syphilis (b = 1.450, p < 0.001) had significant positive effects on oncogenic HPV infection. Ever had anal sex (b = 1.243, p = 0.025) and Age (b = 0.043, p = 0.002) positively drived HPV16 and HPV52 infection, respectively. Anal CA patients who are HIV‐positive, have a history of syphilis, or at least 35 years old should be considered for Hr‐HPV, cytology and other anal cancer related tests to reduce the risk of cancer development.