A new provision passed by Tennessee lawmakers in the waning hours of the legislative session this year would make the state among the toughest in the nation on undocumented immigrants convicted of felonies.

But the measure, which has not yet been signed or vetoed by Gov. Bill Haslam, could lead to a court battle. Courts have struck down similar measures in other states.

Immigration attorneys say the new law is the latest case in which states have tried to implement the "mass deportation" rhetoric pushed by President Donald Trump, highlighted by his travel ban executive orders and pledge to build a wall along the border with Mexico.

"Tennessee is unfortunately following in the Trump mass deportation movement right now," said Melisa Keaney, an attorney with the National Immigration Law Center in California.

The law also can take effect if the governor opts not to sign it for 10 days, not including Sundays. Haslam's office did not respond to a request for comment on the legislation.

The new measure would require judges to consider federal immigration status as a felony sentencing enhancement factor, and use their discretion in making that determination. Enhancements can add between one and 10 years to prison sentences, depending on the offense.

Keaney said immigration status is a federal civil matter, not something states can legally determine, and similar laws have been struck down as unconstitutional in other states.

"I think there are also equal protection and due process challenges, treating individuals differently based on nationality," Keaney said. "There’s no real process. You just have a judge sitting there making a determination about immigration status."

Keaney said the immigration law center would attempt to intervene with court action to prevent the law from taking effect, and expects other organizations to also try and stop the provision.

But the bill's sponsor, Senate Majority Leader Mark Norris, R-Collierville, said "it's consistent with most Tennesseans' concern for our safety."

"I had more extreme legislation proposed to me by constituents," he said, adding the bill is partly related to the state's lawsuit against the federal government over refugee resettlement.

Norris said he had legislative legal staff and district attorneys review the legislation and they did not voice any concern over the bill.

"It's just another tool in the court's kit that the court may use at its discretion," Norris said.

The legislation moved quickly through the Tennessee General Assembly and Republicans pointed to a provision in the bill that says it’s the discretion of the judge, not a requirement, to consider the immigration status when deciding the sentence.

The Judiciary Committee passed it March 28 on a 7-2 vote. The discussion that day centered largely around an Arizona law that was found unconstitutional.

The bill, which would cost the state about $500,000, was discussed again in the Senate Finance Committee in early May.

► More:Feds to ask for dismissal of Tennessee's refugee lawsuit

► More:New poll: Immigrants should have pathway to citizenship, Nashvillians say

It passed that committee the day before the legislative session cleared the Senate and House floors.

The House sponsor was Rep. Ron Gant, R-Rossville, a freshman lawmaker who relied on Rep. William Lamberth, R-Cottontown, an attorney and experienced legislator, to aid in his defense of the bill on the floor. More than 40 House members joined as co-sponsors.

Norris argued immigration status is considered "on the front end" of the criminal process, like when magistrates consider a suspect's flight risk when they determine bond.

Democrats argued against the legislation and said it had no “rational basis” for being enacted.

“It’s just really messy,” said state Sen. Jeff Yarbro, a Nashville Democrat and Harvard-educated attorney who became one the harshest critics of the legislation.

“And the second I started looking at it I think it’s one of the worst immigration bills that we’ve had in years,” he said.

Yarbro said he didn’t research the bill until it was on the floor and used his phone and a few “quick-dial text friends” that could offer some insight. He found a similar bill in Florida that is under discussion.

► More:Immigrants set to protest across Tennessee on International Workers' Day

► More:Conservative Tennessee lawmakers decry in-state tuition for undocumented immigrants

Yarbro said the bill was amended to create more constitutional problems. Initially, the bill used the term "alien," which could apply to immigrants who have visas, but was amended to remove that term, allowing it to apply more broadly.

“But it happened in a week when we were passing three or four other bills of questionable constitutionality,” Yarbro said.

The bill in Florida would create an enhancement factor for just five violent crimes, including murder and placing a bomb, much more narrow than Tennessee’s proposal.

A proposal in Arizona was struck down for being unconstitutional. It would have criminally penalized offenses that are currently civil matters, such as working without a permit and not having immigration paperwork.

► More:In-state tuition for undocumented students fails in House committee

Keaney said those cases and others unfairly target specific nationalities of people and have often been struck down when challenged.

"When it places the determination about whether or not the person is undocumented, that’s something the state is not able to do," Keaney said.

Stephanie Teatro, co-executive director for the Tennessee Immigrant and Refugee Rights Coalition, said there is little precedent for this legislation because it’s so broad and includes any felony — unlike Florida’s proposed legislation.

She also says it's another attempt to implement "failed policies" of the Trump administration.

"Without making a case for how this bill keeps communities safe or advances justice, the legislature has once again singled out a group of Tennesseans for differential treatment, undermining our values of fairness and due process," Teatro said.

Staff writer Ariana Maier Sawyer contributed to this report. Reach Jake Lowary at jlowary@tennessean.com and on Twitter at @JakeLowary.