A bill that would allow illegal immigrants to buy Obamacare plans with their own money is headed to the desk of California Gov. Jerry Brown, after the state Senate passed the measure Thursday.

While President Obama's healthcare law bans illegal immigrants from purchasing Obamacare plans, California is trying to partially change that through what's known as a 1332 waiver. If Brown signs the new measure into law, it would allow the state to petition the federal government to let it allow illegal immigrants to buy plans through Covered California, although they couldn't get federal subsidies.

If California obtains the waiver, it would become the first state to expand the Affordable Care Act to illegal immigrants.

"Covered California should be able to live up to its name and serve all Californians, regardless of immigration status," said Anthony Wright, director of the consumer advocacy group Health Access California.

"People who have different viewpoints on immigration policy can come together in recognition that it is everyone's interest to connect as many Californians with coverage, and prevent the health and financial issues for not just uninsured families but the community as a whole."

The measure passed with bipartisan support in both the state House and the Senate, although the question of allowing illegal immigrants to buy Obamacare plans remains controversial elsewhere. California recently has made some other moves to expand benefits to illegal immigrants, last month extending full benefits to immigrant children enrolled in the state's low-income insurance program, Medi-Cal.

The waiver California is seeking wouldn't make subsidies available to illegal immigrants. But it would allow them to use their own money to buy plans on Covered California, the state's Obamacare marketplace, instead of having to buy directly from insurers.