Brown's signature means that police will be barred from asking people about their immigration status or participating in immigration enforcement activities starting January 1.
Jail officials only will be allowed to transfer inmates to federal immigration authorities if they have been convicted of certain crimes.
California is home to an estimated 2.3 million immigrations without legal authorization.
"These are uncertain times for undocumented Californians and their families, and this bill strikes a balance that will protect public safety, while bringing a measure of comfort to those families who are now living in fear every day," Brown said in statement.
More From This Section
Democrats hope blocking police from cooperating will limit the reach of US Immigration and Customs Enforcement officers.
The measure introduced by the Democratic Senate leader, President Pro Tem Kevin de Leon of Los Angeles, cleared the Legislature with support only from Democrats. Republicans said it will protect criminals and make it harder for law enforcement to keep people safe.
The bill, SB54, originally would have severely restricted the authority of police officers to cooperate with federal immigration authorities. At Brown's insistence, it was scaled back to allow cooperation in jails.
The changes convinced the California police chiefs association to drop its opposition, while sheriffs, elected officials who run jails, remained opposed. ICE Acting Director Thomas Homan has condemned the measure, saying California is prioritizing politics over public safety.
California's Democratic political leaders have enthusiastically battled Trump and his administration with lawsuits, legislation and fiery public rhetoric, particularly about immigration and the environment.