The suit, filed Wednesday by the South Carolina American Civil Liberties Union and others, seeks an injunction to prevent the law from taking effect in January, The (Columbia) State reported.
The plaintiffs argue the law violates the U.S. Constitution's Fourth Amendment protection against unreasonable searches and seizures and would encourage racial profiling.
The law requires law enforcement officers to check the immigration status of anyone they detain, including people pulled over on traffic stops, and creates a statewide Illegal Immigration Enforcement Unit under the state's Department of Public Safety.
"Individuals perceived as 'foreign' by state or local law enforcement agents will be in constant jeopardy of harassment and unlawfully prolonged detention and arrest," the lawsuit states.
The suit also argues the state overstepped its bounds because immigration is the responsibility of the federal government.
The suit names as defendants Gov. Nikki Haley, state Attorney General Alan Wilson, Charleston County Sheriff James Cannon and Scarlett Wilson, the 9th Circuit solicitor in Charleston.
Alan Wilson, who helped write the law, defended it.
"We have a strong opinion this law is constitutional and we're prepared to defend it to the U.S. Supreme Court if we have to," he said.
Similar suits have been filed in over immigration laws in other states, the State said, but federal judges' rulings have not been uniform, meaning the issue likely will end up before the U.S. Supreme Court.