“In India we celebrate the commonality of major differences,” wrote the celebrated author Shashi Tharoor about his native country. “We are a land of belonging rather than of blood.” Indeed, India’s 1.24-billion-strong population is one of the world’s most diverse, with 700 ethnic and language groups and possibly many more, depending on how they are counted. Today, most of these groups keep pretty much to themselves, only rarely marrying outsiders. But a new study concludes that several thousand years ago, the entire subcontinent underwent a period of massive intermarriage, shuffling its population’s genetic deck so thoroughly that it left clear traces—even in the genomes of today’s most isolated tribes.

In recent years, genetic studies of modern Indians have provided a host of new insights into the ancient history of this sprawling nation, which harbors nearly one-sixth of the world’s population. A key finding, reported in 2009 by a team led by geneticist David Reich of Harvard Medical School in Boston, was that most Indians today are descendants of two major population groups: Ancestral North Indians (ANI), who probably migrated into the subcontinent 8000 or more years ago from the Middle East, Central Asia, and Europe; and Ancestral South Indians (ASI), who were native to the region and had been there much longer. The study also showed that these two groups began to mix at some point in the past, although just when was not clear.

Reich and his colleagues teamed up with researchers from the Council of Scientific and Industrial Research Centre for Cellular and Molecular Biology in Hyderabad, India, to take a much closer look at the genetics of modern Indians. Using both newly generated and previously published genetic data from 571 people representing 73 ethnic and language groups, 71 from India and two from Pakistan (which prior to Indian independence from British rule in 1947 was considered part of India), the team analyzed the genetic differences among the subjects using several powerful statistical methods. The analysis included nearly 500,000 genetic markers on the subjects’ DNA.

The results, reported online today in The American Journal of Human Genetics, paint a complex picture: Beginning about 4200 years ago, ANI and ASI populations, which previously had kept mostly separate, began mating together, a flurry of intermarriage that probably lasted more than 2 millennia. Then, beginning about 1900 years ago or somewhat later, mating patterns shifted dramatically. Local populations became entrenched, eschewing intermarriage with other groups and adopting a cultural pattern of what researchers call endogamy, the practice of marrying only within an ethnic or social group.

“There was a major demographic transformation in India from a region where mixture was pervasive to one in which it is very rare because of a shift to endogamy,” says lead author Priya Moorjani, a geneticist at Harvard Medical School.

The traces of this alternating pattern can be clearly seen in the genomes of modern Indians today, the study finds. For example, the percentage of ANI ancestry ranges from a high of 71% in the Pathan ethnic group of northern India to a low of 17% in the Paniya group of southwest India, meaning that the degree of ancient admixture is still measurable and significant in even the most isolated and endogamous ethnic groups.

“The most remarkable aspect of the ANI-ASI mixture is how pervasive it was, in the sense that it has left its mark on nearly every group in India,” Moorjani and her co-workers write.

What accounts for this pattern? The team points out that the period of intermarriage overlaps with a time of huge social upheavals in India, including the collapse of the ancient Indus civilization—which thrived on the Indian subcontinent between about 2600 B.C.E. and 1900 B.C.E.—as well as large-scale population movements and the rise of the Vedic religion, the predecessor of modern Hinduism. But after 1900 years ago, India’s caste system became a major cultural force, the team concludes, based on its new genetic findings and confirmed by evidence from ancient religious texts. The system rigidly defined four social classes, with the Brahmans at the top and the Sudras at the bottom. Intermarriage was not allowed between them. The Rig-Veda, India’s oldest surviving text and a founding document of ancient Hinduism, does not mention the caste system in its earliest sections, probably written some 3000 years ago; only much later are references to it found.

“The bulk of the Rig-Veda describes a society in which there is substantial movement among groups,” Moorjani points out. The four-caste system is only mentioned in an appendix written much later, she says, consistent with the genetic evidence.

The study is “carefully and cautiously crafted,” says Toomas Kivisild, a population geneticist at the University of Cambridge in the United Kingdom, and has “major significance for understanding the complex demographic processes in India that led to the endogamous rules of the caste system.”

Lynn Jorde, a geneticist at the University of Utah in Salt Lake City, calls the results “intriguing,” but cautions that they need to be confirmed with a larger number of samples from even more regions of the Indian subcontinent, as well as with the use of complete DNA sequences from the entire genomes of all the individuals studied.

The team agrees that more needs to be done and suggests that ancient DNA studies of prehistoric burials—which would give scientists a finer grained picture of population mixing in the ancient past—could be the next step in this ongoing research.