Although it is known that individuals living with HIV have a higher HPV prevalence, the impact of individual HPV types on HIV acquisition is less clear. In this prospective cohort study we investigated the relationship between HPV types and incident HIV infection among men who have sex with men (MSM) and transgender women (TW) in Lima, Peru. Six hundred HIV-negative Peruvian MSM and TW participated in a 2-year study with biannual visits. At baseline, participants completed a computerized, self-administered questionnaire on sexual behavior and HPV knowledge and underwent a physical exam including anogenital swabs for HPV DNA (37 genotypes via linear array testing) and HIV testing; follow-up visits included the questionnaire and HIV testing. Participant mean age was 25 years (range = 18-40), with 48.9% self-identifying as gay and 86.5% reporting having sex exclusively with men. At baseline, 530 participants had HPV DNA present (61.1% with high-risk HPV, 84.9% with low-risk HPV). Among 571 participants who returned for any study visit, 73 (12.8%) became infected with HIV during the 2-year follow-up (6% HIV incidence). Compared to those without HIV, more participants with HIV had any HPV type present (97.3% vs. 87.6%, respectively, p = .01), more than one HPV type (79.5% vs. 58.2%, p < .01), or high-risk HPV (72.6% vs. 51.4%, p < .01). Some participants lost to follow-up could have been HIV-positive, which would have affected the relationship of HPV and HIV infection. Our prospective study showed that participants with any HPV type, more than one HPV type, or high-risk HPV were more likely to test positive for HIV. Although most studies have shown HPV-HIV coinfection, our findings illustrate the strong relationship between individual HPV types and HIV infection. This further illustrates the potential utility of HPV vaccine for MSM and TW, not only for HPV prevention but also possibly for HIV prevention.