Background: Patients who do not disclose their sexuality, including men who do not disclose same-sex behaviour, are difficult to characterise through traditional epidemiological approaches such as interviews. Using a recently developed method to detect large networks of viral sequences from time-resolved trees, we localised non-disclosed men who have sex with men (MSM) in UK transmission networks, gaining crucial insight into the behaviour of this group. Methods: For this phylogenetic analysis, we obtained HIV pol sequences from the UK HIV Drug Resistance Database (UKRDB), a central repository for resistance tests done as part of routine clinical care throughout the UK. Sequence data are linked to demographic and clinical data held by the UK Collaborative HIV Cohort study and the national HIV/AIDS reporting system database. Initially, we reconstructed maximum likelihood phylogenies from these sequences, then sequences were selected for time-resolved analysis in BEAST if they were clustered with at least one other sequence at a genetic distance of 4·5% or less with support of at least 90%. We used time-resolved phylogenies to create networks by linking together nodes if sequences shared a common ancestor within the previous 5 years. We identified potential non-disclosed MSM (pnMSM), defined as self-reported heterosexual men who clustered only with men. We measured the network position of pnMSM, including betweenness (a measure of connectedness and importance) and assortativity (the propensity for nodes sharing attributes to link). Findings: 14 405 individuals were in the network, including 8452 MSM, 1743 heterosexual women and 1341 heterosexual men. 249 pnMSM were identified (18·6% of all clustered heterosexual men) in the network. pnMSM were more likely to be black African (p<0·0001), less likely to be infected with subtype B (p=0·006), and were slightly older (p=0·002) than the MSM they clustered with. Mean betweenness centrality was lower for pnMSM than for MSM (1·31, 95% CI 0·48–2·15 in pnMSM vs 2·24, 0·98–3·51 in MSM; p=0·002), indicating that pnMSM were in peripheral positions in MSM clusters. Assortativity by risk group was higher than expected (0·037 vs −0·037, p=0·01) signifying that pnMSM were linked to each other. We found that self-reported heterosexual men were more likely to link MSM and heterosexual women than heterosexual women were to link MSM and heterosexual men (Fisher's exact test p=0·0004; OR 2·24) but the number of such transmission chains was small (only 54 in total vs 32 in women). Interpretation: pnMSM are a subgroup distinct from both MSM and from heterosexual men. They are more likely to choose sexual partners who are also pnMSM and might exhibit lower-risk sexual behaviour than MSM (eg, choosing low-risk partners or consistently using condoms). Heterosexual men are the group most likely to be diagnosed with late-stage disease (ie, low CD4 counts) and non-disclosed MSM might put female partners at higher risk than heterosexual men because non-disclosed MSM have male partners. Hence, pnMSM require specific consideration to ensure they are included in public health interventions. Funding: National Institutes of Health.