PrEP Brasil was a demonstration study to assess feasibility of daily oral tenofovir diphosphate disoproxil fumarate plus emtricitabine provided at no cost to men who have sex with men (MSM) and transgender women at high risk for HIV within the Brazilian public health system. We report week 48 pre-exposure prophylaxis (PrEP) retention, engagement, and adherence, trends in sexual behaviour, and incidence of HIV and sexually transmitted infections in this study cohort. PrEP Brasil was a 48 week, open-label, demonstration study that assessed PrEP delivery at three referral centres for HIV prevention and care in Rio de Janeiro, Brazil (Fundação Oswaldo Cruz), and São Paulo, Brazil (Universidade de São Paulo and Centro de Referência e Treinamento em DST e AIDS). Eligible participants were MSM and transgender women who were HIV negative, aged at least 18 years, resident in Rio de Janeiro or São Paulo, and reported one or more sexual risk criteria in the previous 12 months (eg, condomless anal sex with two or more partners, two or more episodes of anal sex with an HIV-infected partner, or history of sexually transmitted infection [STI] diagnosis). Participants were seen at weeks 4, 12, 24, 36, and 48 for PrEP provision, clinical and laboratory evaluation, and HIV testing. Computer-assisted self-interviews were also done at study visits 12, 24, 36, and 48, and assessed sexual behaviour and drug use. PrEP retention was defined by attendance at the week 48 visit, PrEP engagement was an ordinal five-level variable combining presence at the study visit and drug concentrations, and PrEP adherence was evaluated by measuring tenofovir diphosphate concentrations in dried blood spots. Logistic regression models were used to quantify the association of variables with high adherence (≥4 doses per week). The study is registered with ClinicalTrials.gov, number NCT01989611. Between April 1, 2014, and July 8, 2016, 450 participants initiated PrEP, 375 (83%) of whom were retained until week 48. At week 48, 277 (74%) of 375 participants had protective drug concentrations consistent with at least four doses per week: 183 (82%) of 222 participants from São Paulo compared with 94 (63%) of 150 participants from Rio de Janeiro (adjusted odds ratio 1·88, 95% CI 1·06-3·34); 119 (80%) of 148 participants who reported sex with HIV-infected partners compared with 158 (70%) of 227 participants who did not (1·78, 1·03-3·08); 67 (87%) of 77 participants who used stimulants compared with 210 (71%) of 298 participants who did not (2·23, 1·02-4·92); and 232 (80%) of 289 participants who had protective concentrations of tenofovir disphosphate at week 4 compared with 42 (54%) of 78 participants who did not (3·28, 1·85-5·80). Overall, receptive anal sex with the last three partners increased from 45% at enrolment to 49% at week 48 (p=0·17), and the mean number of sexual partners in the previous 3 months decreased from 11·4 (SD 28·94) at enrolment to 8·3 (19·55) at week 48 (p<0·0013). Two individuals seroconverted during follow-up (HIV incidence 0·51 per 100 person-years, 95% CI 0·13-2·06); both of these patients had undetectable tenofovir concentrations at seroconversion. Our results support the effectiveness and feasibility of PrEP in a real-world setting. Offering PrEP at public health-care clinics in a middle-income setting can retain high numbers of participants and achieve high levels of adherence without risk compensation in the investigated populations. Brazilian Ministry of Health, Conselho Nacional de Desenvolvimento Científico e Tecnológico, Secretaria de Vigilancia em Saúde, Fundação Carlos Chagas Filho de Amparo à Pesquisa do Estado do Rio de Janeiro, and Fundação de Amparo à Pesquisa do Estado de São Paulo.