Oral HPV infection is the main risk factor for the development of oropharyngeal carcinoma. Men who have sex with men (MSM), especially if living with HIV (PLWH), are at increased risk of infection and consequently of cancer development. Aim of this study is to evaluate the impact of nonavalent vaccine on oral HPV infection in a cohort of MSM and transgender women (TGW). This prospective study included all MSM and TGW who started nonavalent HPV vaccination from May 2019 to September 2021. Oral rinse was collected before each vaccine administration and after six months of follow up. Descriptive statistics were used. Kaplan Meier probability curves and Cox regression models for HPV acquisition and clearance were calculated. The analysis included 211 individuals (202 MSM and 9 TGW). PLWH were 138 (65.4%). Baseline oral rinse was positive in 30 subjects (14.2%). Positivity rate did not change over time (p = 0.742), even when restricting the analysis only to high-risk genotypes (p = 0.575) and to genotypes covered by vaccine (p = 0.894). The risk to acquire HPV infection was 12.8% at one year and 33.4% at two years after vaccination. The probability to clear the infection was 67.6% at one year and 87.9% at two years. HIV infection had no impact on vaccine efficacy. Age above 45 years was the only factor associated to HPV acquisition (aHR 4.06, 95% CI 1.03-15.98, p = 0.045). Prevalence of oral HPV infection was higher in PLWH, but HIV had no impact on viral clearance or acquisition after vaccination.