During a 2-year period (2003-2004), tuberculosis (TB) transmission in Barcelona and the factors related to transmission among the Spanish- and foreign-born populations were studied by molecular epidemiology. Data were obtained from TB cases and Conventional Contact Tracing registries and genotyping was performed using restriction fragment length polymorphism (RFLP)-IS6110 and MIRU12 as a secondary typing method. Of the 892 TB cases reported, 583 (65.3%) corresponded to Spanish-born and 309 (34.6%) to foreign-born. Six hundred and eighty-seven cases (77%) were confirmed by culture. RFLP typing of 463/687 (67.4%) isolates was performed, revealing 280 (60.5%) unique and 183 (39.5%) shared patterns, which were grouped into 65 clusters. Spanish-born individuals were significantly more clustered than foreign-born individuals (44.6% vs. 28.8%; p 0.016). Clustering in foreign-born individuals was associated with HIV (p 0.051, odds ratio = 3.1, 95% confidence interval 1-10.9) and alcohol abuse (p 0.022), whereas, in the Spanish-born individuals, clustering was associated with age in the range 21-50 years, (p 0.024). Of the total clusters, 36/65 (55.3%) included only Spanish-born patients, whereas 22/65 (33.8%) included individuals from both populations. In mixed clusters, the index case was Spanish-born in 53% and foreign-born in 47%. Among the foreign-born, 2.8% were ill on arrival, 30% developed TB within the first year and 50.3% developed TB within the first 2 years; 58.3% were from South America. In conclusion, half of the foreign-born TB patients developed the disease during the first 2 years after arrival, which, in most cases, was the result of endogenous reactivation. Recent TB transmission among Spanish-born and foreign-born populations, as well as bidirectional transmission between communities, contributed significantly to the burden of TB in Barcelona, suggesting the need to improve Public Health interventions in both populations.