People from traditionally urban areas could be genetically better suited to fighting infection, say researchers.
The University of London team looked at how many people carried a specific gene variant known to give them resistance to TB and leprosy.
It was more common in those from areas with a longer history of urbanisation, where the diseases were more likely to have been rife at one point.
They described the discovery as an example of "evolution in action".
The phenomenon, reported in the journal Evolution, is suggested as an example of so-called "selective pressure" in relation to disease resistance.
It happens because, when a population is exposed to a killer illness, the people who are best placed to pass on their genes to the next generation are those whose genetic make-up helps them fight the infection.
In towns and cities, where people intermingle far more closely, the likelihood of being exposed to infectious disease is theoretically higher.
So, over the centuries, the greater the level of historical exposure, the more likely it is that these resistance genes will be spread widely among the population.
The scientists, from University College London and Royal Holloway, part of the University of London, tested this by analysing DNA samples drawn from 17 different human populations living across Europe, Asia and Africa.
The results were cross checked against historical and archaeological data about the date of the first city or urban settlement in each region.
The protective gene variant was found in nearly everyone from the Middle East to India and in parts of Europe where cities have been established for thousands of years, but were less frequent in regions with a shorter history of urbanisation, such as Africa.
Dr Ian Barnes, one of the authors of the research, said: "This seems to be an elegant example of evolution in action.
"It flags up the importance of a very recent aspect of our evolution as a species, the development of cities as a selective force.
"It could also help explain some of the differences we observe in disease resistance around the world."
There are other examples of selective pressure in disease resistance - it has been suggested that one is the prevalence of the gene defect responsible for the lung disease cystic fibrosis.
Normally, the lethal nature of the condition across history would suggest that people carrying the gene defect were at a distinct evolutionary disadvantage, and their numbers would be fewer.
However, scientists believe that the gene gives carriers an advantage when faced with the cholera toxin - which, in early cities, could have significantly outweighed the disadvantage of some children developing cystic fibrosis.
Professor Brian Spratt, chair of molecular microbiology at the Imperial College London School of Public Health, said: "Individuals who are more resistant to a pathogen that causes a disease with substantial mortality, such as malaria or TB, will survive better and will contribute more offspring to the next generation. As many of their children will have inherited increased resistance to the pathogen, they also will survive better.
"Thus frequencies of these genetic sequences that provide increased protection to a disease will be far more common in areas where the disease has been killing people for centuries or even millennia than those where the disease has never been endemic.
The same effect should occur for some diseases with populations who have lived for centuries within dense cities because diseases such as cholera and TB will have always been a problem in cities due to overcrowding and poor sanitation, compared to people living nomadic lives."