(CNN)They started swarming across America's border, millions of desperate families fleeing poverty or seeking political asylum.
But many people were repelled by their presence. Some warned that the country was facing a "genetic invasion" and that whites were "losing the demographic game." Another said, "There will no longer be an America for Americans."
One leader even thought of a radical way to keep them out.
"Can we build a wall high enough around this country so as to keep out these cheaper races?" he asked.
That scenario may sound familiar, but it's actually a description of early 20th century America. The country was gripped by a demographic panic. That fear, along with mounting anxieties about crime and poverty, led to one of the most shameful episodes in American history.
"The Eugenics Crusade," an American Experience film that premiered on PBS Tuesday night, recounts how America responded to those fears. The country's leaders tried to breed a better race, and millions of American citizens were enthusiastic backers.
It was an ugly time. The eugenics mania that swept the country in the late 19th and early 20th centuries led to forced sterilizations and the passage of laws in 27 states designed to limit the numbers of those considered genetically unfit: immigrants, Jews, African-Americans, the mentally ill and those deemed "morally delinquent."
How American laws inspired the Nazis
The engrossing two-hour film, though, is about something deeper than science. It is about fear -- how fear of "the other" can corrupt even the most brilliant minds. The film shows how an iconic inventor, a Nobel physics laureate and a brilliant Supreme Court justice all embraced the pseudoscience.
The crusade also found champions in social reformers like birth control proponent Margaret Sanger and W.E.B. DuBois, one of the founders of the NAACP. DuBois saw no irony in calling for African-Americans to "breed for better brains, for efficiency, for beauty."
The film, written and directed by Michelle Ferrari, is filled with jaw-dropping moments: newsreel footage of white American families merrily competing in "genetic fitness" contests at state fairs where they were measured like livestock; a retelling of a pivotal court case where a teenage mother was forcibly sterilized by her mother; and the story of how the irrepressible inventor of Kellogg's Corn Flakes became a champion of eugenics.
One the most chilling parts of the film, which is available online, involves an appearance by Adolf Hitler. Ferrari shows how America's sterilization policies inspired Nazi Germany's leaders to launch their own eugenics program, which later led to genocide.
Hitler actually wrote a fan letter to one of the biggest backers of eugenics in America, a wealthy lawyer named Madison Grant, who wrote a book, "The Passing of a Great Race."
"Your book was my bible," Hitler told Grant.
Few people today, however, know about this period in American history.
"It's like this dirty secret that people whisper to each other once in a while," says Nathaniel Comfort, a professor at Johns Hopkins University in Baltimore who is featured in the film.
"It's uncomfortable. It's ugly," Comfort says. "It's a nasty part of our country's history that's not very fun to confront. It's not very pretty to think about ways in which Nazi eugenics policies were practically modeled on American eugenics policies."
Why eugenics was so seductive
Behind every movement there's a powerful personality. The eugenics crusade had Charles Davenport, a slender, Ivy League-educated scientist whose dignified demeanor exuded an air of authority. The PBS film shows why Davenport was the right man to spread the wrong idea.
He was ambitious, a shrewd manipulator of the media, and he knew how to attract the support of wealthy patrons to spread his eugenics ideas to powerful politicians. It was Davenport who called for a wall to be built around America to keep out the "cheaper races."
Davenport was inspired by the work of Sir Francis Galton, who is credited with starting the eugenics movement during the late 19th century. A cousin of the famed naturalist Charles Darwin, Galton theorized that humans could control their own evolution. His proposal: Pair the most intelligent and fit so that their children would boost the "breeding stock" of the human race.
That proposition, of course, led to the next question: What do we do about those deemed not fit or intelligent? The eugenics crusade provided a monstrous answer: Ban them from reproducing.
The solution was so seductive because it bore the authority of science. The America of the early 20th century was torn by social ills: massive inequality, urban squalor, tensions over immigration.
Eugenics gave reformers a scientific answer to these problems. If social ills were caused by "feebleminded" people with bad genes, as many eugenics champions argued, why not make the world better by eliminating bad genes?
"Just as we have strains of scholars, military men, we have strains of paupers, of sex offenders, strains with strong tendencies toward larceny, assault, lying, running away," Davenport once told a reporter. "The costs to society of these strains is enormous."
It was a planned extinction of the most marginalized people in society -- dressed up as a way to better society.
Why eugenics ideas persist
The crusade to build a better race eventually became a quest to build a whiter race. The film shows how lobbying from eugenics proponents helped push Congress to pass the Immigration Act of 1924. It banned the entry of Asian immigrants and limited Eastern and Southern Europeans for more than four decades.
"To some extent humanity has always been about 'othering' -- there's us and there's the other," says Adam Cohen, a writer and historian featured in the film. "The eugenics movement gave this scientific punch to this idea that there's us and there are others, and we are the right people. We're the people that's not only important to favor now, but we're the people who have to own the future."
The film shows how the eugenics crusade was finally stopped by several factors: A counterattack from the scientific community, changing attitudes toward poverty triggered by the Great Depression, and later revelations about Nazi atrocities.
But the core idea of eugenics -- an overwhelming faith that everything in human nature is determined by our genes -- persists, says Comfort, author of "The Science of Human Perfection: How Genes Become the Heart of American Medicine."
He calls this notion "genetic determinism" and alluded to some of its assumptions in a recent article for Nature magazine.
Want to explain why students of color do poorly on tests? Look at their genes, the theory goes, not lack of support.
"But the benefits of good teaching, of school lunches and breakfasts, of having textbooks and air conditioning and heating and plumbing have been established irrefutably," Comfort writes. "And they actually are causal: We know why stable blood sugar improves mental concentration."
Then there is another disturbing shadow from the eugenics movement that lingers.
People talk openly now about creating "designer babies" due to advances in gene therapy. This is the world envisioned in sci-fi movies like "Gattaca," where society is divided between wealthy people who engineer physically perfect babies and those who can only have children the natural way.
Comfort writes that such a world would be a nightmare:
"People would be defined at birth by their DNA. Expectations would be set, and opportunities, resources and experiences would be doled out — and withheld — a priori, before anyone has had a chance to show their mettle."
Comfort is not so sure that humanity can resist the eugenics impulse to breed better human beings. The belief that genes are the primary determinant of a person's success is seductive because it can absolve people of blame, he says.
"The allure of the innate is very real. Genes. Blood. Your basic inborn identity. It sounds like the ultimate answer to life, the universe, and everything," Comfort says.
"What makes a eugenicist is this overwhelming faith that everything in human nature is determined by your genes," he says. "This takes different forms in different places. We need to know how it manifests itself in these different periods right down to this day."
In some ways the eugenics crusade marches on.