As hundreds of demonstrators massed, mostly peacefully, at the capitol plaza, the governor, speaking at a state building a few miles away, said the law “represents another tool for our state to use as we work to solve a crisis we did not create and the federal government has refused to fix.”

The law was to take effect 90 days after the legislative session ends, meaning by August. Court challenges were expected immediately.

Hispanics, in particular, who were not long ago courted by the Republican Party as a swing voting bloc, railed against the law as a recipe for racial and ethnic profiling. “Governor Brewer caved to the radical fringe,” a statement by the Mexican American Legal Defense and Educational Fund said, predicting that the law would create “a spiral of pervasive fear, community distrust, increased crime and costly litigation, with nationwide repercussions.”

While police demands of documents are common on subways, highways and in public places in some countries, including France, Arizona is the first state to demand that immigrants meet federal requirements to carry identity documents legitimizing their presence on American soil.

Ms. Brewer acknowledged critics’ concerns, saying she would work to ensure that the police have proper training to carry out the law. But she sided with arguments by the law’s sponsors that it provides an indispensable tool for the police in a border state that is a leading magnet of illegal immigration. She said racial profiling would not be tolerated, adding, “We have to trust our law enforcement.”

Ms. Brewer and other elected leaders have come under intense political pressure here, made worse by the killing of a rancher in southern Arizona by a suspected smuggler a couple of weeks before the State Legislature voted on the bill. His death was invoked Thursday by Ms. Brewer herself, as she announced a plan urging the federal government to post National Guard troops at the border.

Image Gov. Jan Brewer signed the bill, SB 1070, on Friday. Credit... Monica Almeida/The New York Times

President George W. Bush had attempted comprehensive reform but failed when his own party split over the issue. Once again, Republicans facing primary challenges from the right, including Ms. Brewer and Senator John McCain, have come under tremendous pressure to support the Arizona law, known as SB 1070.