Hazleton, Pa., in October. (Jessica Kourkounis for The Washington Post)

— Starting a decade ago, a group of small U.S. cities began passing laws to block undocumented immigrants from living within their borders.

They were a collection of mostly white exurbs and faded manufacturing towns whose populations suddenly were transforming. More Latinos were arriving in search of jobs, and the towns’ leaders complained of burdened schools and higher crime.

Here in this northeastern Pennsylvania city, then-Mayor Lou Barletta said he would do what he could to restore “law and order” and take back his city. It was time, Barletta said, for a “war on the illegals.”

And while that sentiment is shared among some advisers to President Trump, the experiences of these towns show how measures targeting undocumented immigrants can leave lasting and bitter racial divisions while doing little to address the underlying forces that often determine where newcomers settle.

The laws in most cases aimed to make it illegal for landlords to rent to undocumented immigrants and threatened fines for employers who hired them. But among the six most high-profile towns that tried to pass such laws, all have been foiled by court rulings, settlements or challenges with enforcement. Several have been ordered to pay the legal fees for the civil rights groups that brought suits. And in five of the six towns, the Latino population — legal or illegal — has continued to grow, attracted by a continued rise in low-paying jobs.

“It wound up costing our city $9 million in attorney’s fees,” said Bob Phelps, the mayor of Farmers Branch, Tex., a Dallas suburb that saw its ordinance defeated in court after a seven-year legal battle. “And we accomplished zero.”

The local efforts were championed by two men who are now Trump advisers and reportedly were considered for Cabinet positions. Kansas Secretary of State Kris Kobach, who counseled most of the cities in their legal challenges, consulted with Trump during his campaign about issues including a border wall with Mexico. Barletta is now a U.S. House member and was part of Trump’s transition team.

Trump on Wednesday rolled out the first phase of what is expected to be sweeping immigration policy changes, signing orders for the construction of a border wall and the targeting of “sanctuary cities” that resist the deportation of undocumented immigrants. His administration is also considering tighter restrictions on refugees from several Muslim-majority countries. Trump has more latitude to carry out immigration policy changes than states or cities do, but his policies could face legal challenges — or bring about unintended economic consequences.

“These ideas are more easy to sell as political talking points than as real policy options,” said Muzaffar Chishti, the director of the Migration Policy Institute at the New York University School of Law. “Just because you say you want to do something doesn’t mean you’ll be able to.”

Difficulties with enforcement

The towns that took action — Hazleton; Farmers Branch; Valley Park, Mo.; Riverside, N.J.; Escondido, Calif.; and Fremont, Neb. — did so largely out of frustration, fed up with swift demographic changes and what they saw as the rising costs of caring for undocumented residents. The newcomers were drawn by cheaper housing costs and new industries that attracted low-wage labor.

“The presence of illegal aliens places a fiscal burden on the city,” Fremont’s ordinance read.

(Alice Li/The Washington Post)

At the same time, the federal government’s inability to seal the border was helping to drive an argument that towns and states had the legal right to do a job that Washington could not manage. Kobach, a longtime activist who worked at the time for the legal arm of the Federation for American Immigration Reform, sought to use those towns as a testing ground for his aggressive stance. Most of the laws were passed in a flurry between 2006 and 2007.

Although immigration enforcement had long been the purview of the federal government, finding those who had crossed the border illegally or overstayed visas was not doable without the help of local law enforcement, said Rosemary Jenks, the director of government relations at NumbersUSA, which favors a reduction in immigration.

“You should help states and localities do what they want to do voluntarily in order to help the enforcement of immigration law,” Jenks said.

But localities have not gotten the chance. In Hazleton and Farmers Branch, federal judges ruled the ordinances discriminatory and unconstitutional. In Escondido, the town quickly backed away after a challenge by the American Civil Liberties Union. In Valley Park, the town’s mayor decided to no longer enforce what his predecessor had put in place. In Riverside, as legal bills piled up, the city council rescinded the ordinance, fearing damage to businesses. Dozens of other towns considering “Illegal Immigration Relief Act” laws backed off.

The municipality that has come the closest to successfully implementing such a law is Fremont, a meatpacking town west of Omaha where a six-year court fight, financed through a tax increase, won the city the right to ban undocumented immigrants from rental housing. But just as the city’s officials put the law in place in 2014, they realized it would not be effective: Fremont’s rental applications, with their wording approved by the courts, did not require the information, such as a Social Security number, that could help determine whether a person was in the United States legally.

Courts also have weakened several states’ illegal-immigrant laws, most notably in Arizona. Michael Hethmon, who is senior counsel for the Immigration Reform Law Institute and helped Kobach handle the Hazleton case, said that the local efforts have faced more setbacks than victories but that the towns’ money has been “well spent” in taking a stance. The towns had no data on the number of undocumented residents before or after the ordinances, making it difficult to measure how well the laws worked in driving away that part of the population.

“If you compare our advocacy struggle to other issues — civil rights issues or LGBT — you have to remember that those folks lost a lot more [at the beginning] before they ultimately prevailed,” Hethmon said.

The battles over the local ordinances, residents of those towns say, helped create fault lines that remain visible. Escondido in 2014 rejected a permit for a shelter that would have housed unaccompanied minors who had come across the southwest U.S. border; a new ACLU lawsuit alleges that the rejection was driven by anti-immigrant sentiment. In Fremont, the town has been split by a proposed new Costco poultry processing plant — one that would add hundreds of jobs but probably would accelerate the arrival of immigrants.

“The makeup of our town has really changed, and again with this chicken plant, there’s going to be a majority of low-income jobs that will not bring us taxpayers and homeowners,” said Dawn Wiegert, 55, who has lived in Fremont for 25 years. “People that will be a burden on all of our other resources — I don’t know how else to say it without sounding racist.”

In Hazleton, the first place to propose an illegal-immigrant law, some of the tensions have worsened with the proliferation of social media, said Joleen Reis, 24, a Hazleton day-care worker who is one of the few who straddle the white and Latino communities. Her father came to Pennsylvania from Peru as a migrant worker and met her mother, who is white.

Reis pulled up a local-news page on Facebook. The latest item mentioned a police report — two men in dark clothing stealing from vehicles.

“So are you ready for America without illegals?” one commenter said. “Because I am!”

“Filthy animals!” another said. “Send them back somewhere now!”

Reis sighed.

“I try not to read this stuff, typically,” Reis said. “But they assume everyone is illegal. And it’s always ‘us’ versus ‘them.’ ”

Blamed for town’s woes

Tucked under the crisscross of highways near the Pocono Mountains, Hazleton had endured the slow-motion decay common in blue-collar manufacturing and mining towns, only this time there was a twist: A newer set of state tax breaks helped lure a blitz of distribution centers, as well as a Cargill slaughterhouse, to the outskirts of town. The Latino population, at 4 percent in 2000, had soared to 38 percent by 2006, with many Dominicans moving from the Bronx and Brooklyn in search of jobs and cheaper housing. Barletta said he was concerned about higher crime rates, and when a 29-year-old was killed, allegedly by undocumented immigrants, he decided to act.

He searched on his computer about get-tough laws on immigration, finding an ordinance, debated but never passed, written by the city council in San Bernardino, Calif. Barletta copied the text almost verbatim. Hazleton’s ordinance would make it illegal for businesses to hire undocumented immigrants and called for fines for landlords who rented to them.

Several months later, Hazleton had a new law and CNN trucks outside its city hall.

Barletta emphasized that he opposed only those in the United States illegally and was driven to act by several obvious problems: The population was booming, but the tax base wasn’t — a sign, he said, of undocumented immigrants not contributing to the system. Schools were spending more money to educate Spanish-speaking students. Hazleton’s woefully understaffed police force — short by about 30 officers — was struggling to deal with an uptick in violent crime.

“I saw how it affected the lives of people, our emergency rooms, our schools,” Barletta said in an interview. “A mayor had to take the stand. Listen, it wasn’t fun — trust me. When my dog barked in the middle of the night, I had a shotgun under my bed.”

The law easily won the city council’s approval, but its enforcement was held up by an injunction and a lawsuit brought by civil rights groups, including the ACLU. In court, some of Barletta’s arguments for the law ran into trouble: He said he didn’t know how many undocumented immigrants lived in Hazleton or how many had committed crimes. The town hadn’t studied it.

A federal judge eventually ruled that the law was illegal because it usurped the federal government’s power and would affect not just undocumented immigrants but “those who look or act as if they are foreign.” Other courts upheld that ruling over eight years. Kobach, paid $250,000 by Hazleton, did not respond to multiple requests seeking comment.

In 2015, a federal judge ordered Hazleton to pay $1.4 million to the lawyers who had fought the town.

The city, with a budget of $9 million, took out a bank loan and cut a check to the ACLU, said Joseph Yannuzzi, the mayor who succeeded Barletta.

“With that money,” Yannuzzi said, “we could have hired 12 police officers.”

‘No choice about the changes’

Latinos now constitute 50 percent of Hazleton’s population. They’ve opened up carnicerias and beauty salons and boutiques along once-decrepit Wyoming Street. They tend to be younger and much likelier to work than Hazleton’s white residents, according to census data, and now make up much of the labor force at the airport-size distribution centers of American Eagle and Amazon.com (whose chief executive, Jeffrey P. Bezos, owns The Washington Post). Hazleton native Joe Maddon, the manager of the Chicago Cubs, several years ago opened up a community center aimed at building closer relationships between whites and Hispanics.

“To be honest, residents who were here before don’t have no choice about the changes,” said Eric Garcia, 37, a Dominican who moved to Hazleton from New York in 2005 and owns a photo studio.

But many longtime residents, unnerved by the influx of foreigners, have left the city limits for what they call the “valley” suburbs. With an immigration message similar to Barletta’s, Trump won nearly 60 percent of the votes in Hazleton’s Luzerne County.

Jamie Longazel, a Hazleton native and University of Dayton sociologist who in 2016 published a book about his home town, “Undocumented Fears,” said that Barletta, with his ordinance, introduced a “villain” that people barely talked about beforehand. Longazel found in his research that only 0.7 percent of crimes in Hazleton between 2001 and 2006 had been committed by undocumented immigrants.

“I don’t want to made it sound like Hazleton is only full of backwards racists,” said Longazel, who conducted focus groups and interviews with longtime white residents. “I want to emphasize this point that a lot of the scapegoating we see is top-down. Politicians are speaking this language and then we tend to echo it, rather than there being malicious intent from the bottom.”