BackgroundTuberculosis (TB) is a major public health problem requiring complex treatment, the success of which depends on biological, social, and institutional factors. São Paulo State (SPS), in Brazil, has a high TB burden. Because of high socioeconomic heterogeneity and chaotic urbanisation, homelessness might play an important role in the TB burden in SPS. Our aim was to determine the association between homelessness and outcome of treatment of pulmonary TB (PTB) in SPS.MethodsA historical cohort from the routine SPS TB database for 2009-2013 was analysed. The study population was newly diagnosed adult patients with PTB. Homelessness was ascertained at notification or when treatment started. Our outcome was unsuccessful outcome of treatment. We used logistic regression to adjust for potential confounders and multiple imputation for missing data.ResultsWe analysed 61,817 patients; 1726 (2.8 %, 95%CI 2.7-2.9 %) were homeless. Homeless patients were concentrated in bigger cities, were more frequently middle-aged males, had black/brown skin colour, and had received less education (P < 0.001, for all). Alcohol and drug use was three times more frequent in homeless patients (43.2 % vs 14.4 %, 30.2 % vs. 9.4 %, P < 0.001, respectively). HIV testing was less common among the homeless, of whom 17.3 % were HIV positive compared with 8.5 % among the not homeless population (P < 0.001). Microbiologic confirmation was more frequent among the homeless (91.6 % vs. 84.8 %, P < 0.001). Unsuccessful outcome of treatment was 57.3 % among the homeless and 17.5 % among the not homeless (OR = 6.32, 95%CI 5.73-6.97, P < 0.001), mainly due to loss to follow-up (39 %) and death (10.5 %). After full-adjustment for potential confounders, homelessness remained strongly associated with lower treatment success (aOR = 4.96, 95 % CI 4.27-5.76, P < 0.001). HIV status interacted with homelessness: among HIV-infected patients, the aOR was 2.45 (95%CI 1.90-3.16, Pinteraction < 0.001). The population attributable fraction for the joint effect of homelessness, alcohol and drug use was almost 20 %.ConclusionsConfirming our hypothesis, homelessness led to a marked reduction in the successful treatment of newly diagnosed pulmonary tuberculosis. Homelessness and associated conditions were important contributors to lack of treatment success in pulmonary tuberculosis in São Paulo. A multifaceted intervention must be implemented to target this vulnerable population.Electronic supplementary materialThe online version of this article (doi:10.1186/s12916-016-0584-8) contains supplementary material, which is available to authorized users.