WASHINGTON – The Supreme Court upheld an Arizona law Thursday that penalizes businesses for hiring workers who are in the United States illegally, rejecting arguments that states have no role in immigration matters.

By a 5-3 vote, the court said that federal immigration law gives states the authority to impose sanctions on employers who hire unauthorized workers.

The ruling cheered supporters of tougher immigration laws who said it would encourage states to take new steps, especially in the employment area.

The decision upholding the validity of the 2007 law comes as the state is appealing a ruling that blocked key components of a second, more controversial Arizona immigration enforcement law. Thursday’s decision applies only to business licenses and does not signal how the high court might rule if the other law comes before it.

Still, the ruling placed the court’s five Republican appointed justices on the side of the state and against the Chamber of Commerce, which challenged the law along with the American Civil Liberties Union.

Chief Justice John Roberts, writing for the majority, said Arizona’s employer sanctions law “falls well within the confines of the authority Congress chose to leave to the states.”

Justices Stephen Breyer, Ruth Bader Ginsburg and Sonia Sotomayor, all Democratic appointees, dissented. The fourth Democratic appointee, Justice Elena Kagan, did not participate in the case because she worked on it while serving as President Obama’s solicitor general

Breyer said the law upsets a balance in federal law between dissuading employers from hiring illegal workers and ensuring that people are not discriminated against because they may speak with an accent or look like they might be immigrants.

Employers “will hesitate to hire those they fear will turn out to lack the right to work in the United States,” he said.

The Obama administration backed the challenge to the law. The measure was signed into law in 2007 by Democrat Janet Napolitano, then the governor of Arizona and now Obama’s Homeland Security secretary.

The employer sanctions law has been only infrequently used. It was intended to diminish Arizona’s role as the nation’s hub for immigrant smuggling by requiring employers to verify the eligibility of new workers through a federal database. Employers found to have violated the law can have their business licenses suspended or revoked.

Rep. Lamar Smith, R-Texas, chairman of the House Judiciary Committee, praised the high court’s decision. “Not only is this law constitutional, it is commonsense. American jobs should be preserved for Americans and legal workers,” Smith said.