Crafted carefully, state laws can be written that would allow Texas to crack down on undocumented immigrants and illegal border crossers without running afoul of the U.S. Constitution, a state attorney told lawmakers recently.

In at least one case, he said, it's already happened.

The guidance comes as Republican lawmakers continue accusing the Obama administration of failing to secure the border, citing the recent influx of undocumented immigrants from Central America into the Rio Grande Valley. The issue was thrust back into the spotlight on Tuesday when Gov. Greg Abbott ordered the Texas National Guard to stay in the Rio Grande Valley despite earlier plans to end its deployment this month.

During a House State Affairs committee hearing last week on border security and immigration, Texas Deputy Attorney General Brantley Starr told lawmakers they have more options than they might think to flex state legal muscle in the traditionally federal realm of immigration enforcement.

The Texas Tribune thanks its sponsors. Become one.

Although the U.S. Supreme Court has ruled that “foreign policy and related matters, such as immigration, are one of the few enumerated powers the federal government has,” Starr said states do have some room to work.

“You do have the ability to create state-level offenses that have an immigration element to them as long as they are sufficiently unique,” he said, citing House Bill 11, the Legislature’s 2015 omnibus border security bill.

The bill, signed by Abbott in June, made it a state felony to smuggle someone into the country for pay. Starr said he believes the bill would stand up to a court challenge on Constitutional grounds if one were brought. (There is no current challenge, the attorney general’s office confirmed.)

“There were new state-level elements to that offense [in] that you’re taking money in exchange for bringing someone across the border illegally,” he said. “And the addition of the new state-level elements to that offense made it sufficiently unique.”

The new laws are already helping state police apprehend alleged criminals that federal agents might let go, Texas Department of Public Safety Director Steve McCraw told the committee.

Border Patrol agents and state troopers recently came across a stash house for undocumented immigrants, for instance, where eight people, including two pregnant women, were being held against their will, McGraw said. Because the state had jurisdiction in its own right, state police could make the arrests.

The Texas Tribune thanks its sponsors. Become one.

“With Border Patrol and the U.S. Attorney’s office, it was too low under their threshold,” he said. “[The state] can go to the district attorney’s office and say, ‘Wait a minute,’ and the district attorney took that offense.”

Starr also said he believes state lawmakers can pass a bill outlawing "sanctuary cities" that would withstand a court challenge. The Supreme Court upheld one of four provisions of a controversial Arizona law, SB 1070, dubbed the “show me your papers” bill, allowing police to ask a person if they were in the country legally, Starr said.

But it didn’t take away the power of the federal government to deport the person, which is why it wasn't struck down.

“That law survived because it could be implemented in a way that ultimately left discretion to the federal government to detain that person and remove them from the country,” he said.

Starr said that an essential element to a Texas "sanctuary cities" bill would be carving out an exception for school districts because the Supreme Court has already ruled that students cannot be questioned about their immigration status. The school exception was included in the state's 2011 proposal that failed to make it to former Gov. Rick Perry's desk.

Jacqueline Watson, the president of the American Immigration Lawyers Association’s Texas chapter, warned the committee the issue isn't as simple as the state made it seem.

“This opinion does not foreclose other pre-emption and constitutional challenges to the law,” she said.

She said the Arizona bill shouldn’t be seen as a blueprint or viewed as a license for officers to stop a person solely on immigration matters.

The Texas Tribune thanks its sponsors. Become one.

"A state officer is required to make reasonable attempts to determine the immigration status of any person they stop, detain or arrest on some other legitimate basis if reasonable suspicion believes that the person is an alien and is unlawfully present in the United States," she said.