Men who have sex with men (MSM) are vulnerable to HPV infection. This study aims to explore the HPV infection status at different sites among HIV-positive MSM, HIV-negative MSM, and men who have sex with women (MSW), and to investigate their willingness to receive HPV vaccination. From September 2023 to April 2024, three groups were recruited in Tianjin, China. Participants completed an electronic self-administered questionnaire, which included demographic information, knowledge related to sexually transmitted diseases, behavioral information, and willingness to receive the HPV vaccine. Samples were collected from the anal region, genitals, and oral cavity for HPV typing. A total of 1,559 participants were recruited, including 300 HIV-positive MSM, 600 HIV-negative MSM, and 659 MSW. The HPV infection prevalence for any site were 62.0, 53.7 and 8.3%, respectively (p < 0.001). The infection prevalence for HPV genes covered by the 9-valent vaccine were 47.0, 36.8, and 3.5%, respectively (p < 0.001). Co-infection prevalence at anal and genital were 20.3, 14.2, 0.6%, respectively. Co-infection prevalence at anal and genital and oral were 1.3, 0.3%, 0, respectively. A total of 77.0% HIV-positive MSM and 75.3% HIV-negative MSM expressed willingness to receive the HPV vaccine, whereas 58.9% of MSW were unwilling (p < 0.001). Being HIV-positive (aOR, 3.119; 95% CI, 2.213-4.395), being over 46 years old (aOR, 1.994; 95% CI, 1.266-3.142), with an occupation classified as "white collar workers" (aOR, 1.620; 95% CI, 1.111-2.362) and "freelancing" (aOR, 2.025; 95% CI, 1.371-2.993) and a history of homosexual behavior in the past 6 months (aOR, 5.338; 95% CI, 3.802-7.495) were risk factors for HPV infection among men in Tianjin. Consistently using condoms in the past 6 months (aOR, 0.667; 95% CI, 0.513-0.867) were protective factors. The HPV infection prevalence among MSM in Tianjin is significantly higher than among MSW, with higher prevalence in the anal region compared to the genital and oral region. HPV infection is associated with HIV infection, older age, and homosexual behavior. Most MSM showed a positive willingness to receive the HPV vaccine, indicating the necessity to implement targeted HPV vaccination programs for MSM and to enhance necessary preventive knowledge and behavioral interventions.