It's the states vs. their cities.

The issue: Illegal immigration.

A growing number of proposed state laws designed to crack down on sanctuary cities are putting local leaders in those municipalities on the defensive, forcing many to fight off measures they say could cripple their crime-fighting abilities and threaten economic growth.

At least 31 states are considering legislation this year that would ban sanctuary policies, according to the National Conference of State Legislatures. Many of those bills face fervent opposition from mayors and other officials of progressive cities.

The battle unfolding between state and city lawmakers is largely the result of a broader national question that President Donald Trump has made front and center: How should the government deal with legal and illegal immigration?

"Our current immigration laws are outdated and dysfunctional" and that has resulted in states and cities trying to address immigration issues in competing ways, said Avideh Moussavian, a senior policy attorney at the National Immigration Law Center.

"Localities know these populations benefit them economically and want to protect them," she said, adding that "many states tend to think there is some clean and orderly fix, like a 'ban,' which is ridiculous."

In Florida, lawmakers considered a bill earlier this year that would punish local officials, in cities like Miami, for not complying with federal immigration efforts. In Wisconsin, state lawmakers have proposed similar measures, despite resistance from officials in Madison, the capital, where Mayor Paul Soglin has repeatedly said he won't act as an agent of the federal government when it comes to immigration policy.

While some of the proposed bills are likely to go nowhere and are symbolic in nature, many are the result of an increased focus in taking on sanctuary cities coming from Trump’s Justice Department.

During a recent speech in Long Island, the president vowed that he'd be "cracking down on sanctuary cities that defy federal law, shield visa overstays, and that release dangerous criminals back into the United States’ communities."

"So many deaths where they release somebody back into the community, and they know it’s going to end that way," he said.

Trump signed an executive order during his first week in office in January directing the withholding of federal funds from sanctuary cities — a broad label for cities that provide less than full cooperation with federal immigration authorities. Last month, Attorney General Jeff Sessions announced that cities stood to lose millions in future federal grant money if they don't help federal agents deport suspected undocumented immigrants held in local jails.

In July, Sessions announced new rules for applying for money under a federal grant program that provides roughly $250 million in crime-finding aid to states and local governments. And last week he threatened to withhold certain federal funding from four specific sanctuary cities, Baltimore, Albuquerque and Stockton and San Bernardino, Calif., according to the Associated Press.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

Officials in several cities, including Chicago, San Francisco and New York, have said they are prepared to file suit against the Trump administration. And in April, a federal judge in California blocked the Trump administration from withholding current grant money from cities that resist cooperation with ICE.

"Chicago will not be blackmailed into changing our values, and we are and will remain a welcoming city," Mayor Rahm Emanuel said in a statement Sunday announcing his city's plans to sue the Trump administration.

President Donald Trump signs two executive orders during a visit to the Department of Homeland Security with Vice President Mike Pence, Homeland Security Secretary John Kelly and other officials on Jan. 25. Chip Somodevilla / Chip Somodevilla/picture-allianc

The intense White House attention to the issue has emboldened states to write their own proposals attempting to strip sanctuary cities of state funding — a move that has in many states further ratcheted up already existing tensions between diverse urban areas that often deal most directly with undocumented immigrants, and more conservative rural areas that don’t.

One of the most prominent battlefields is Texas, where Republican Gov. Greg Abbott in May signed a controversial state law prohibiting local governments in the state from enacting policies that prevent local officials from sharing immigration-related information with the federal government.

City officials across Texas have expressed outrage that they’re being told how to deal with sensitive immigration issues they say they’re well equipped to handle.

"It really feels like they’re waging war, that there’s a war on cities happening in this country and right here in this state," said Austin Mayor Steve Adler, a Democrat, referring to "SB4," which directs local officials to cooperate with requests issued by the federal government to detain people who may be in the U.S. illegally.

Steve Adler, mayor of Austin, speaks during the Bloomberg Breakaway Summit on May 25, 2016 in New York. Michael Nagle / Bloomberg via Getty Images file

Austin, which had the second-fastest-growing economy among cities in the U.S. in 2015 and remained one of the most robust in 2016, according to federal economic data, thrives because its "inclusive values and culture" attract "people who want to live and work here," Adler said.

Those arguments, however, haven’t persuaded Abbott. Earlier this year, during the run-up to the bill’s passage, Abbott threatened to "bring the hammer down" and simply cut off millions of dollars of state funding to Travis County, where Austin is located.

The tensions aren’t unique to Texas.

Nearly 2,000 miles away, in Rhode Island, legislators are debating several immigration proposals, including one that would subject officials in sanctuary cities in the state, including its capital Providence, to criminal or civil penalties for not complying with new federal guidelines.

That bill would also "allow Rhode Island citizens to file a complaint with the attorney general if they believe an agency is not complying with it and states that if the allegation proves true, the offending agency shall not be eligible to receive any funds from the state until the violation has ceased."

Providence's Democratic Mayor Jorge Elorza, who would be personally subject to penalty under that bill, told NBC News he’s furious that state lawmakers aren’t taking input from local leaders into account.

Providence Mayor Jorge Elorza at the Providence premiere of "Bleed For This" on November 10, 2016 in Providence, Rhode Island. File Scott Eisen / Getty Images for Open Road Films file

"These bills take valuable and scarce public resources we use to go after very serious criminals and redirects them to go after petty criminals and investigate people’s immigration statuses," he said. Such measures "only serve to create anxiety,” Elorza continued, "and not just for people here without papers, but lawmakers and officials, too."

Rhode Island state Rep. Arthur Corvese, a Democrat and the sponsor of two of anti-sanctuary city bills, has repeatedly defended his proposals.

"We have immigration laws for good reason, and it is for the safety of Rhode Islanders that our state should not stand in the way of their proper enforcement," he said earlier this year.

Abbott, too, has dismissed criticism of the Texas law — which is slated to go into effect Sept. 1 but remains tied up in court due to suits from various cities — arguing that it's simply about public safety.

"My wife is the first Hispanic first lady" of the state, he told NBC News in May. "They have absolutely nothing to fear. The only people who face any type of consequence are criminals. If you commit a crime and you're wanted by the federal government, then, yes, you have something to be concerned about. If you haven't committed a crime, and you're not wanted by the federal government, you have no concern."

Critics, however, including law enforcement officials and immigration experts, have warned measures like that actually make their communities less safe because they redirect resources, undermine criminal cases and destroy relationships with marginalized people, including victims and witnesses.

Several recent studies show that crime levels in immigrant communities are significantly lower than those in the general population. One such study, by the American Immigration Council, a nonprofit immigrant-rights advocacy group, of census data from 1980 to 2013 found that only 1.6 percent of immigrant males ages 18 to 39 were incarcerated, compared to 3.3 percent of native-born males in the same age range.

Immigration hardliners dispute those studies.

Attorney General Jeff Sessions at the U.S. Embassy in San Salvador, El Salvador, on July 27, 2017. Sessions was in El Salvador to step up international cooperation against the violent street gang MS-13. Pablo Martinez Monsivais / AP

"Sanctuary policies create sanctuaries for criminal aliens, period," said Hans von Spakovsky, a senior legal fellow at the Heritage Foundation, a conservative think tank, and a member of Trump's voter integrity commission.

Adler, the mayor of Austin, said he found the divide between states and their cities on immigration to be the result of partisanship and dysfunction in Washington trickling down to state capitals.

"I look at the federal government, which seems to be so polarized and not able to get anything done," he said. "And then I look at Austin. It used to be that Austin had its differences with the state Legislature by virtue of Austin just being a progressive place. This year, there seems to be a lot more animosity."