BackgroundThe HIV epidemic in key populations such as men who have sex with men (MSM) is a public health issue of worldwide concern. China has seen an increase in newly diagnosed HIV infections through male–male sexual contact in the past decade. In a long-term cohort, how the complex behaviour pattern of MSM changed and the association with the HIV risk are unclear at present.MethodsThis study was conducted from October 2011 to December 2019 in Tianjin. MSM were recruited by snowball sampling through online and offline ways. Demographic and sexual behavioural data were collected for analysis. Three indicators (condom use in last anal sex, frequency of condom use during anal sex and the number of sexual partners) were used to define the behaviour change. Participants with zero, one, and two or three risk indicators were categorised into behaviour types of ‘protective’, ‘moderate’, and ‘fragile’, respectively. Change in behaviour type between baseline and each visit was considered. Time-varying Cox models were performed to evaluate HIV infection risk.ResultsOf 2029 MSM included in the study, 127 were new HIV diagnoses. The overall incidence rate was 3.36 per 100 person-years. The percentage of ‘protective’ and ‘moderate’ behaviour types had a conspicuous growth trend as the follow-up. Furthermore, the HIV incidence rate in each visit among different behaviour transition types showed a general downward trend as the number of total follow-up times increased. Individuals who remained in ‘fragile’ (adjusted HR (aHR): 25.86, 95% CI: 6.92 to 96.57) or changed from ‘protective’ to ‘moderate’ (aHR: 4.79, 95% CI: 1.18 to 19.47), ‘protective’ to ‘fragile’ (aHR: 23.03, 95% CI: 6.02 to 88.13), and ‘moderate’ to ‘fragile’ (aHR: 25.48, 95% CI: 6.79 to 95.40) between baseline and the last follow-up had a higher HIV risk. Gained risk indicators were associated with the increase of HIV risk (gained one indicator, aHR: 2.67, 95% CI: 1.68 to 4.24; gained two or three indicators, aHR: 4.99, 95% CI: 3.00 to 8.31) while losing just one risk indicator could halve the risk (aHR: 0.43, 95% CI: 0.21 to 0.90).ConclusionsAmong MSM in Tianjin, it is necessary to get timely behaviour change for those with high-incidence behaviour patterns while sustaining for those with low-incidence patterns.Trial registration numberChinese Clinical Trials Registry (ChiCTR2000039500).