BACKGROUND: HIV transmission in men who have sex with men (MSM) in the UK has shown no sign of decreasing in the past decade. Additional prevention measures are needed. We aimed to estimate the effect of various potential interventions implemented individually and in combination on prevention of HIV infection. METHODS: We extended a deterministic partnership-based mathematical model for HIV transmission, informed by detailed behavioural and surveillance data, to assess the effect of seven different HIV interventions implemented in MSM (aged 15-64 years) in the UK during 2014-20, including increasing rates of HIV testing, test-and-treat programmes, pre-exposure prophylaxis (PrEP), and sexual behavioural changes. We did sensitivity analyses on risk compensation. FINDINGS: We predicted a baseline of 16 955 new infections (IQR 13 156-21 669) in MSM in the UK during 2014-20. At a coverage of ≤50%, testing twice a year outperformed all other interventions. Of all intervention combinations, only the combined effect of test and treat and annual HIV testing (61·8%, IQR 47·2-81·8, of total incidence) was greater than the sum of effects of the two interventions individually (32·6%, 23·7-46·0, and 23·9%, 16·5-33·3, respectively). Simultaneous PrEP, expansion of HIV testing, and initiation of test-and-treat programme in 25% of high-activity MSM could save 7399 (IQR 5587-9813) UK MSM from HIV infection (43·6%, IQR 32·9-57·9, of total incidence). An increase in unsafe sex or sexual partners to 50% or more could substantially reduce the effect of interventions, but is unlikely to negate the prevention benefit completely. INTERPRETATION: PrEP could prevent a large number of new HIV infections if other key strategies including HIV testing and treatment are simultaneously expanded and improved. Without PrEP, HIV incidence in MSM in the UK is unlikely to decrease substantially by the end of this decade. FUNDING: Health Protection Agency (now Public Health England).