BACKGROUND: Robust age-specific estimates of anal human papillomavirus (HPV) and high-grade squamous intraepithelial lesions (HSIL) in men can inform anal cancer prevention efforts. We aimed to evaluate the age-specific prevalence of anal HPV, HSIL, and their combination, in men, stratified by HIV status and sexuality. METHODS: We did a systematic review for studies on anal HPV infection in men and a pooled analysis of individual-level data from eligible studies across four groups: HIV-positive men who have sex with men (MSM), HIV-negative MSM, HIV-positive men who have sex with women (MSW), and HIV-negative MSW. Studies were required to inform on type-specific HPV infection (at least HPV16), detected by use of a PCR-based test from anal swabs, HIV status, sexuality (MSM, including those who have sex with men only or also with women, or MSW), and age. Authors of eligible studies with a sample size of 200 participants or more were invited to share deidentified individual-level data on the above four variables. Authors of studies including 40 or more HIV-positive MSW or 40 or more men from Africa (irrespective of HIV status and sexuality) were also invited to share these data. Pooled estimates of anal high-risk HPV (HR-HPV, including HPV16, 18, 31, 33, 35, 39, 45, 51, 52, 56, 58, 59, and 68), and HSIL or worse (HSIL+), were compared by use of adjusted prevalence ratios (aPRs) from generalised linear models. FINDINGS: The systematic review identified 93 eligible studies, of which 64 contributed data on 29 900 men to the pooled analysis. Among HIV-negative MSW anal HPV16 prevalence was 1·8% (91 of 5190) and HR-HPV prevalence was 6·9% (345 of 5003); among HIV-positive MSW the prevalences were 8·7% (59 of 682) and 26·9% (179 of 666); among HIV-negative MSM they were 13·7% (1455 of 10 617) and 41·2% (3798 of 9215), and among HIV-positive MSM 28·5% (3819 of 13 411) and 74·3% (8765 of 11 803). In HIV-positive MSM, HPV16 prevalence was 5·6% (two of 36) among those age 15-18 years and 28·8% (141 of 490) among those age 23-24 years (ptrend=0·0091); prevalence was 31·7% (1057 of 3337) among those age 25-34 years and 22·8% (451 of 1979) among those age 55 and older (ptrend<0·0001). HPV16 prevalence in HIV-negative MSM was 6·7% (15 of 223) among those age 15-18 and 13·9% (166 of 1192) among those age 23-24 years (ptrend=0·0076); the prevalence plateaued thereafter (ptrend=0·72). Similar age-specific patterns were observed for HR-HPV. No significant differences for HPV16 or HR-HPV were found by age for either HIV-positive or HIV-negative MSW. HSIL+ detection ranged from 7·5% (12 of 160) to 54·5% (61 of 112) in HIV-positive MSM; after adjustment for heterogeneity, HIV was a significant predictor of HSIL+ (aPR 1·54, 95% CI 1·36-1·73), HPV16-positive HSIL+ (1·66, 1·36-2·03), and HSIL+ in HPV16-positive MSM (1·19, 1·04-1·37). Among HPV16-positive MSM, HSIL+ prevalence increased with age. INTERPRETATION: High anal HPV prevalence among young HIV-positive and HIV-negative MSM highlights the benefits of gender-neutral HPV vaccination before sexual activity over catch-up vaccination. HIV-positive MSM are a priority for anal cancer screening research and initiatives targeting HPV16-positive HSIL+. FUNDING: International Agency for Research on Cancer.