Background: Syphilis incidence worldwide has rebounded since 2000, particularly among men who have sex with men (MSM). A predictive model for syphilis infection may inform prevention counselling and use of chemoprophylaxis. Methods: Data from a longitudinal cohort study of MSM and transgender women meeting high-risk criteria for syphilis who were followed quarterly for 2 years were analysed. Incidence was defined as a four-fold increase in rapid plasma reagin (RPR) titres or new RPR reactivity if two prior titres were non-reactive. Generalised estimating equations were used to calculate rate ratios (RR) and develop a predictive model for 70% of the dataset, which was then validated in the remaining 30%. An online risk calculator for the prediction of future syphilis was also developed. Results: Among 361 participants, 22.0% were transgender women and 34.6% were HIV-infected at baseline. Syphilis incidence was 19.9 cases per 100-person years (95% confidence interval (CI) 16.3-24.3). HIV infection (RR 2.22; 95% CI 1.54-3.21) and history of syphilis infection (RR 2.23; 95% 1.62-3.64) were significantly associated with incident infection. The final predictive model for syphilis incidence in the next 3 months included HIV infection, history of syphilis, number of male sex partners and sex role for anal sex in the past 3 months, and had an area under the curve of 69%. The online syphilis risk calculator based on those results is available at: www.syphrisk.net. Conclusions: Using data from a longitudinal cohort study among a population at high risk for syphilis infection in Peru, we developed a predictive model and online risk calculator for future syphilis infection. The predictive model for future syphilis developed in this study has a moderate predictive accuracy and may serve as the foundation for future studies.