“This is not American. This is not who we are.” The words have the thrum of a chant, a staccato denial. After Donald Trump announced his travel ban on people from seven Muslim-majority countries, the words were pronounced by Hillary Clinton, Julia Louis-Dreyfus, Andrew Cuomo. They were scrawled on signs and posted on Facebook and repeated at rallies. This is not American. This is not who we are.

But the words are more an incantation than an accurate description, built on hope not history. For all the recitations of Emma Lazarus — give me your tired, your poor, your huddled masses — the story of American openness to immigrants and refugees is more cramped, more Trumpian, than our national myths suggest. In order to understand and undo the Muslim ban (and given the prioritization of religious minorities in those seven countries, a Muslim ban it is) we need to understand why it is in fact in line with our history, even as it feels so un-American.

When the Chinese Exclusion Act went into effect in 1882, the United States was a racially stratified nation, one in which white Americans had more political rights and economic opportunities than others. So it is perhaps no surprise that the first comprehensive immigration restriction was about protecting both white identity and white economic opportunity.

The Breitbart-Bannon view of immigration has deep roots in American history

In congressional debate about the bill, proponents portrayed Chinese immigrants as unassimilable: too backward, too undemocratic, too foreign. “Chinese civilization has drawn more from the darkness of the medieval ages than from the light of the 19th century,” said George Hazelton, a Minnesota representative, before arguing the Chinese worker community “lives in herds and sleeps like packs of dogs in kennels.” California Rep. Romualdo Pacheco said that a Chinese worker’s “hideous immoralities” were “as natural to him as the yellow hue of his skin.”

China was the first target of a slow-spreading drive to restrict immigration. It reached Japan in 1907, when Theodore Roosevelt halted immigration in an agreement with the nation’s emperor. Ten years later, it engulfed most of Asia after legislation created a barred zone that stretched all the way to India. These immigration restrictions were coupled with court rulings that denied citizenship to any Asian immigrant already in the United States.

Immigration restriction, at first limited to Asia, expanded in the early 1920s, when a nativist drive led to a draconian quota system that slashed immigration levels to 2 percent of the foreign-born population in 1890. The rule applied country by country — 51,200 Germans per year, 2,250 Russians, 1,100 Africans — effectively freezing the ethnic mix of the nation in place. Because that year fell before the largest wave of immigration to the United States, the quota system heavily favored northern and western Europe.

By the 1920s, then, the United States had slammed shut the “sea-washed, sunset gates” that Lazarus had immortalized in the 1883 poem at the Statue of Liberty’s base. This had been done in large part to keep the nation white and Protestant. Arguments in the 1920s against Eastern European immigration mirrored those against Chinese immigration: The immigrants were swarthy idolators, ill-suited for democracy. Just as in the 1880s members of Congress railed against the Chinese for their “heathen superstitions,” so did Americans in the 1920s argue that the Italians were too Catholic, the Slavs too Orthodox, the Russians too Jewish. And all were insufficiently white.

Restrictionists also made economic arguments about immigrants driving down wages and displacing native-born workers. But these arguments did not just live alongside the ones about race and religion — they were bound up with one another. Being nonwhite, non-Christian, and non-native were qualities that made someone less worthy of being given a job, or, if hired, less worthy of a well-paying job.

Add in the other ways of shoring up a distinctly white nationalism, such as the “repatriation” of Mexican Americans in the 1930s and the rejection of Jewish refugees in the 1940s, and suddenly Donald Trump’s Muslim ban seems awfully American after all. So why does it still feel so false to our national creed?

Yet even in the 1800s, Americans spoke up against excluding immigrants

We can find some of the answers back in the 1880s, when Chinese exclusion began. Exclusionists won, but they were not unopposed. Republicans who 15 years earlier fought for the rights of African Americans now sought to stop the exclusion of others based on their race. When Charles Joyce of Vermont rose to object to the ban, he invoked a somewhat fictionalized history of open doors. “To other nations of the earth … it must appear strange and unaccountable that a country inhabited by a people made up of immigrants from every race under Heaven should … attempt to build around its territory a wall against foreigners.”

In the decades that followed, politicians repeated this call for a more open and inclusive immigration policy. Both Grover Cleveland and Woodrow Wilson vetoed bills requiring literacy tests for immigrants, arguing that America was a place of opportunity for the poor and the persecuted.

But it was Harry Truman who best laid out the moral failings of restrictions based on race and culture. In vetoing a 1952 immigration bill (a veto Congress would override), Truman took on the central logic of the quota system: “The idea behind this discriminatory policy was, to put it baldly, that Americans with English or Irish names were better people and better citizens than Americans with Italian or Greek or Polish names,” he wrote in his veto statement. “Such a concept is utterly unworthy of our traditions and our ideals.”

More than that, though, Truman understood that in the early days of the Cold War, when the people of Eastern Europe were facing tyranny from within, the United States had a special duty to provide asylum to these refugees. “We do not need to be protected against immigrants from these countries — on the contrary we want to stretch out a helping hand, to save those who have managed to flee into Western Europe, to succor those who are brave enough to escape from barbarism, to welcome and restore them against the day when their countries will, as we hope, be free again.”

An underappreciated side of Lyndon Johnson’s civil-rights agenda

Truman was out of step with the politics of his day. But those policies were changing. In 1965, at the crest of the black civil rights movement, Lyndon Johnson signed into law a new immigration act that dismantled the quota system. Johnson saw the new immigration law as of a piece with the Civil Rights Act of 1964 and the Voting Rights Act of 1965 — all of them battering rams against a system of discrimination that had harmed so many people.

“This system violated the basic principle of American democracy — the principle that values and rewards each man on the basis of his merit as a man,” he said, speaking from the base of the Statue of Liberty where he signed the bill. “It has been un-American in the highest sense, because it has been untrue to the faith that brought thousands to these shores even before we were a country.”

This argument, that restrictions based on race and creed and culture were un-American, wove diversity into the fabric of American immigration law. It did so imperfectly; gay immigrants, for instance, were banned until 1990. Before that, those coming into the country faced questioning and psychiatric examinations, especially if their dress or mannerisms did not conform to gender expectations, and they could be deported if arrested for homosexual acts. In 1982, a gay person seeking entry to the US was turned away after immigration officials read his letters and diary. Nativism emerged again and again, especially targeted at immigrants from Mexico — as in the case of California’s Proposition 187, in the 1990s. And in recent years the US. has accepted far fewer refugees per capita than many other nations.

The idea of an open, inclusive immigration system nonetheless became a central part of the national story. Johnson himself helped it along, treating the quotas as an exceptional moment that had come to an end: “We can now believe that it will never again shadow the gate to the American Nation with the twin barriers of prejudice and privilege.” And every president — until now — has spoken about unbiased immigration policy as a positive good, as something wholly, and perhaps uniquely, American.

The further the nation moved from 1965, the more natural it has become to expect American immigration laws to be blind to race and religion, that maybe that was the way it always had been.

It’s tempting to believe that the period from 1882 to 1965 was simply an exception, a deviation from true American values. Progressives as well as conservatives tend to make a god of American nationalism and proclaim themselves defenders of the one true church. This is not American. This is not who we are.

The problem, of course, is that this is precisely who we are: a nation built on white nationalism and democracy, slavery and civil liberties, exclusion and inclusion, sin and grace. A nation that boldly declared a principle of radical equality while steadily constructing an architecture of discrimination.

This matters, because it is another reminder that our constitutional system can bear a tremendous amount of illiberalism. The Constitution, Supreme Court, and checks and balances were all in place when the country slammed shut its doors in the 1880s and again in the 1920s. They were still there three months ago when Trump won the election, and two weeks ago when he was sworn into office, and yesterday — when he did whatever insane thing he did the day before you’re reading this. None of those safeguards are self-executing; none will automatically protect “American values,” because “American values” include both America at its best and America at its very worst.

For now, that means the Muslim ban and the mass protests to stop it are both American. The battle between the two, not its outcome, is who we are.

Nicole Hemmer, a Vox columnist, is the author of Messengers of the Right: Conservative Media and the Transformation of American Politics. She is an assistant professor at the University of Virginia’s Miller Center and co-host of the Past Present podcast

The Big Idea is Vox’s home for smart, often scholarly excursions into the most important issues and ideas in politics, science, and culture — typically written by outside contributors. If you have an idea for a piece, pitch us at thebigidea@vox.com.