California’s legislature approved “sanctuary state” protections for illegal aliens in a last-minute vote Saturday, limiting city and state police cooperation with federal immigration officials.

The Associated Press reports that California lawmakers approved SB-54, which would place new restrictions on how local police and federal immigration officials interact.

The approved bill will now head to Gov. Jerry Brown’s desk for approval.

Brown, who has announced his support for the bill after the state Senate leader agreed to allow corrections officers to cooperate with immigration officials, is expected to sign SB-54 into law.

The Los Angeles Times reports that Republican legislators and sheriffs strongly opposed the bill, which passed 27-11 along party lines.

The bill’s last-minute vote came after lawmakers extensively negotiated the details, according to the Hill.

The bill’s final draft was completed Monday, but California law requires bills to be published in their final state for a minimum of 72 hours before a vote. California’s House approved the bill on Friday, and the Senate followed suit with its last-minute vote early Saturday.

The final version bans law enforcement from asking about immigration status or partaking in immigration enforcement efforts. It also prohibits local law enforcement from arresting people on civil immigration warrants.

Police and sheriff’s offices, along with corrections officers in jails and prisons, can work with federal immigration officers to deport illegal aliens if they have been convicted of a felony or a misdemeanor that can be charged as a felony.

However, they will be barred from handing over illegal aliens to federal authorities if they have only been convicted of minor offenses.

It will also prohibit illegal aliens from remaining in jail for longer periods of time for their non-immigration-related crimes before immigration officials take them into custody.

California’s approval of the bill comes a day after a federal judge blocked the Justice Department’s move to withhold grant money from “sanctuary cities.”