The molecular epidemiology of HIV-1 is constantly changing, mainly as a result of human migratory flows and the high adaptive ability of the virus. In recent years, Spain has become one of Europe's main destinations for immigrants and one of the western European countries with the highest rates of HIV-positive patients. Using a phylogeographic approach, we have analyzed the relationship between HIV-1 variants detected in immigrant and native populations of the urban area of Madrid. Our project was based on two coincidental facts. First, resistance tests were extended to naïve and newly diagnosed patients, and second, the Spanish government legislated the provision of legal status to many immigrants. This allowed us to obtain a large data set (n ؍ 2,792) from 11 Madrid hospitals of viral pol sequences from the two populations, and with this unique material, we explored the impact of immigration in the epidemiological trends of HIV-1 variants circulating in the largest Spanish city. The prevalence of infections by non-B HIV-1 variants in the studied cohort was 9%, rising to 25% among native Spanish patients. Multiple transmission events involving different lineages and subsubtypes were observed in all the subtypes and recombinant forms studied. Our results also revealed strong social clustering among the most recent immigrant groups, such as Russians and Romanians, but not in those groups who have lived in Madrid for many years. Additionally, we document for the first time the presence of CRF47_BF and CRF38_BF in Europe, and a new BG recombinant form found in Spaniards and Africans is tentatively proposed. These results suggest that the HIV-1 epidemic will evolve toward a more complex epidemiological landscape.