On the 2016 campaign trail, immigration has been a flash point unlike any other. But as Donald Trump pushes his scheme to build a wall across America’s southern border and Hillary Clinton promises to go further than President Obama in protecting migrants without documentation, a major immigration reform a half-century ago is a reminder that policy changes often don’t go as planned. For today’s politicians, perhaps the biggest takeaway of the Immigration and Nationality Act is to expect unintended consequences.

It was back in 1965, during the depths of the Cold War and the peak of the civil rights movement, that the United States overhauled its immigration laws. Working with liberal Democrats and liberal Republicans (who existed back then), President Lyndon Johnson pushed a bill that did away with the “national origins quota” system. The old quota system, in place since the 1920s, determined who could immigrate to the U.S. based on ethnicity, with a heavy tilt toward Western Europeans—especially the English, Irish and Germans. Only small allotments were granted to Eastern Europeans, Asians and Africans.

That became an issue for the United States in the ‘60s, when new countries were emerging from colonialism, pitting the U.S. and the Soviet Union in a contest for their allegiances. Republican Senator Jacob Javits, a liberal from New York, noted in September 1965 that the immigration system, with its bias toward Western Europeans, “remains today a target for Communist propaganda…making our effort to win over the uncommitted nations more difficult.”

The racial discrimination inherent in the quota system clashed with the idealism of Civil Rights and Voting Rights Acts. And most of all, the ethnic limits ran contrary to many Americans’ image of their country. “As President Kennedy so aptly stated, we are a ‘nation of immigrants,’” Massachusetts Republican Senator Leverett Saltonstall told his colleagues during the debate on the bill. “There is scarcely an area of our national life that has not been favorably affected by the work of people from other lands.”

By ‘65, however, some conservatives in the U.S. House publicly “worried about the size and scale of future Latin American immigration,” says Dan Tichenor, a professor of political science at the University of Oregon, “and were trying to put barriers in its way.” Liberal lawmakers didn’t like that idea, but they doubted that the new restrictions would have much impact. The limits were high enough, Senator Javits conceded, that immigration from the Western Hemisphere under the new law “would be approximately the same as the level reached last year”—a modest 140,000 or thereabouts. Yet the total number of persons of Mexican origin in the U.S. went from 5 million in 1970, the first census after the act, to almost 34 million today.

The Western Hemisphere cap was one key concession that opponents of Johnson’s immigration reform were able to extract. The other significant change was that visas be prioritized for migrants with family ties in the United States. Johnson and the bill’s supporters backed a system that would have put a priority on skill, which ended up being secondary in the new law.

When Johnson signed the Immigration and Nationality Act at the foot of the Statue of Liberty 50 years ago this October, he declared that the new law undoing the old quota system was “not a revolutionary bill. It does not affect the lives of millions.” In fact, it did. The new system, which opened up American immigration to the world, has dramatically shifted the blend of people coming to the country while contributing to the surge in immigrants from Mexico and Latin America entering the U.S. without documentation—neither of which its authors ever intended.

There were “a whole series of consequences unleashed” by this new law, says UCLA Law professor Hiroshi Motomura, author of Americans in Waiting: The Lost Story of Immigration and Citizenship in the United States. Though the 1965 law eliminated ceilings on visas for specific ethnicities across Asia and Africa, it did keep a cap in place for the Eastern Hemisphere—encompassing migrants from Europe, Africa and Asia. As a compromise, it also set the cap on immigration from the Western Hemisphere for the first time. That’s right: The U.S. used to allow unlimited immigration from Mexico. Even as restrictionists had layered on more and more limits on immigrants, starting with the Chinese in the 1880s, the Japanese around the turn of the century, and the rest of Asia, Africa and much of Europe in the 1920s, the U.S. allowed the open flow of immigration from Canada and nations to the south, part of what was considered a “good neighbor” policy.

The conservatives who backed a system of giving a majority of visas to family members of U.S. citizens “thought we would see an expansion in Southern and Eastern European immigration,” says Tichenor. “They never really anticipated the dramatic increase in Asian and Latin American immigration” that resulted thanks to family unification rules. Essentially, the new law allowed American citizens to obtain visas for not only their small children and spouses, but also their sisters and brothers and adult children, who then became citizens and began the process over again.

That started a slow but steady progression of Asian and Latino migration, which had only small populations in the United States before ‘65. In the 1950s, Europeans made up 56 percent of those immigrants obtaining lawful permanent residence in the U.S., while those from Canada and Latin America were 37 percent, and all of Asia accounted for a measly 5 percent, according to Department of Homeland Security statistics. By this past decade, however, Europeans had dropped to just 14 percent of new lawful permanent residents, compared with 35 percent from Asia and 44 percent from the Americas.

One more factor had a major impact: At the same time immigration law was shifting in 1965, a new national workforce policy was also kicking in. A year earlier, in 1964, the federal government ended what was known as the Bracero Program, launched during World War II’s labor shortages to provide temporary laborers from Mexico to American farms and fields. But the program was rife with worker abuses and ardently opposed by labor unions, which believed the migrants pushed down wages for Americans. That opposition finally succeeded in halting the Bracero Program in ’64, to the consternation of the agriculture industry.

Proponents of the move in the Department of Labor and elsewhere believed they could wean farmers off Mexican labor. But “many of the same people who were coming under the Bracero Program or their relatives or the people who were in those networks continued to come,” says Boston College professor Peter Skerry, an expert on immigration and ethnic politics. It’s just that now they came illegally. Over the ensuing decades, that reality combined with the new caps on migrants from Latin America turned what had been legal migration, illegal.

Economic trends in both Latin America and the U.S. also encouraged more migration. As Motomura explains it, 1965 was the “beginning of a mismatch of the legal immigration system and the demands of the economy.” Specifically, urbanization and economic dislocation drove Mexicans and other Central Americans from rural areas north in search of work, while Americans were obtaining higher levels of education and moving away from menial labor. “In 1950, more than half of the labor force were high school dropouts. Now it’s less than 5 percent,” notes Tamar Jacoby, president of the business-backed coalition ImmigrationWorks USA. The law’s drafters “didn’t foresee that.” That’s an understatement.

The lesson of unintended consequences is something advocates on both sides of today’s immigration debate acknowledge. “The first lesson is: Don’t believe everything a politician tells you. As we’ve seen with all kinds of social innovations from the 1960s and 1970s, the assurances of their promoters turn out to be incomplete or false,” says Mark Krikorian, the head of the Center for Immigration Studies, which advocates for much tighter controls on immigration. He and Jacoby agree that the family migration provisions have pushed the system out of whack. But they’re vehemently divided over whether the country still needs robust immigration, and if unmet labor demand is at the root of America’s glut of undocumented migrants.

Disagreements on immigration ultimately come down to a debate over what America should be and how its economy should work. Though President Johnson promised the law “ will not reshape the structure of our daily lives,” the ensuing shifts in population and migration patterns has indeed meant “big changes in American life,” says Skerry, for good and for ill. The last time politicians hashed out a new immigration system, they didn’t entirely weigh those implications. Today’s leaders would be wise to think about the ripple effect before they mess with the borders.