Transgender people are disproportionately affected by HIV and other sexually transmitted infections (STIs) worldwide, and culturally competent prevention and treatment services are often unavailable or inaccessible. Despite recent improvements in national HIV responses for many key populations in east Africa, evidence of effective responses informed by transgender sexual health needs is sparse. We aimed to assess gender identity among men and transgender people who have sex with men in Kenya, and to explore its associations with sexual health-related outcomes, risk behaviours, and uptake of HIV prevention and care interventions. We did a cross-sectional study in Nairobi, Kenya, and recruited adult cisgender men and transfeminine people who reported having sex with men, through respondent-driven sampling. Inclusion criteria were possession of a valid study coupon, being aged 18 years or older, having male sex assignment at birth or male gender identification currently, living within 50 km of Nairobi, and having had consensual anal or oral sexual activity with a man in the previous 12 months. Seed participants were identified by three community organisations that provide targeted health-care services to gay, bisexual, or other men who have sex with men (MSM) communities in Nairobi. We assessed gender identity, sociodemographics, sexual behaviour, and HIV prevention and care uptake, by self-completed survey. Participants were tested for HIV, syphilis, and rectal and urethral gonorrhoea and chlamydia. We compared prevalence of sexual health outcomes, risk behaviour, and HIV prevention and care service uptake among transfeminine and cisgender participants, using multivariable robust Poisson regression models, with gender identity as the independent variable. Between May 4 and Dec 8, 2017, we enrolled 618 participants. Six participants did not answer the questions on sex assigned at birth and gender identity and so were excluded from the analyses. 522 (sample-weighted percentage 86%) of 612 participants were classified as cisgender men, 70 (11%) as transfeminine, and three (<1%) as transmasculine. 17 participants (2%) did not identify as male, female, or transgender. Compared with cisgender men, transfeminine people were more likely to be HIV-positive (28 [41%] of 70 transfeminine vs 151 [25%] of 521 cisgender men; p=0·0009) and to report current symptoms consistent with a rectal STI (eight [16%] of 67 vs 38 [7%] of 518; p=0·014). Transfeminine people reported higher numbers of recent male sexual partners (22 [27%] of 70 transfeminine people reported four or more male sexual partners in the past 3 months vs 112 [13%] of 522 cisgender men; p=0·042) and were more likely to report condomless anal intercourse with men (43 [62%] of 70 vs 208 [39%] of 522; p=0·0009) and receptive anal intercourse (54 [76%] of 70 vs 252 [46%] of 522; p<0·0001) in the past 3 months, and transactional sex with men (42 [57%] of 69 vs 240 [42%] of 518; p=0·023) and experience of sexual assault (16 [23%] of 69 vs 65 [11%] of 520; p=0·019) in the past 12 months. Use of pre-exposure prophylaxis and post-exposure prophylaxis was low in both groups. Transfeminine people who have sex with men have a higher burden of HIV and associated risk behaviours compared with cisgender MSM in the same context, yet their uptake of prevention and care services is poor. Policies should acknowledge the specific needs of transfeminine people as distinct from cisgender MSM, and support health-care providers to address these needs. Evidence for HIV Prevention in Southern Africa (EHPSA), UK Aid.