Arizona police officers will no longer detain people solely to investigate their immigration status under a settlement reached on Thursday.

PHOENIX — Arizona police officers will no longer detain people solely to investigate their immigration status under a settlement reached on Thursday after a lawsuit challenged the so-called “show your papers” provision of an immigration law.

The settlement agreement ends a long and costly court battle between the state and civil rights groups over the 2010 law, which opponents say has led to racial profiling and wrongful detentions.

“This makes it clear that you cannot detain someone even for a minute based on the belief the person is undocumented,” said Karen Tumlin, legal director of the National Immigration Law Center, one of the parties to the suit. “This is a ground-breaking shift.”

The deal, filed in federal court in Phoenix, still must be formally approved by U.S. District Court Judge Susan Bolton.

Under the agreement, the state clarifies that local authorities have limited power to enforce federal immigration laws.

In addition to banning immigration-only arrests, the settlement says law enforcement officers cannot prolong traffic stops to check the immigration status of drivers and passengers.

The guidelines to be used by local officers are contained in an informal opinion issued by Arizona Attorney General Mark Brnovich filed with the court as part of the settlement to end the litigation of the controversial, first-in-the-nation law, commonly known as SB 1070.

The measure, which required police officers to check the immigration status of everyone they stopped, sparked nationwide controversy when signed into law in April 2010 by then Arizona Gov. Jan Brewer. Business groups canceled conventions in Arizona and performers refused to play as protesters rallied throughout the Southwestern state.

Arizona shares a 368-mile border with Mexico and Brewer said the federal government was not doing enough to combat illegal immigration into Arizona.

The Obama administration challenged the law, saying the federal government had jurisdiction over immigration enforcement. The U.S. Supreme Court in 2012 partially struck down the law, including a provision requiring immigrants to carry paperwork at all times.

But the high court upheld the law’s most controversial section, which required police officers to check the immigration status of people they stop, even for minor offenses, the so-called ‘show your papers’ provision.

The groups backing the lawsuit continued to challenge it, and in September 2015, Bolton upheld the “show your papers” provision, rejecting claims by the civil rights coalition that it discriminated against Hispanics.

The ruling was in the process of being appealed when the settlement was reached.