SACRAMENTO, Calif. — Nearly 7 million California workers will be automatically enrolled in a retirement savings account under legislation Gov. Jerry Brown signed Thursday in an attempt to address growing fears that many workers will be financially unprepared to retire.

The legislation creates a state-run retirement program for workers who don’t have an employer-sponsored plan, many of them working in lower-wage positions. It requires employers to automatically enroll their workers and deduct money from each paycheck, though workers can opt out or set their own savings rate. The account could also be carried from job to job.

Supporters of the concept hope that requiring workers to affirmatively opt out will make them less likely to do so, allowing them to set aside a retirement nest egg over time so they don’t have to rely solely on Social Security in their post-work years. A third of all American workers — and two-thirds of part-time workers — don’t have access to a retirement plan through their employer, the Pew Charitable Trusts reported in September, relying on U.S. Census Bureau data.

“It’s something very important now in today’s age of spend now, worry about it later,” said Brown, a Democrat who often warns about the long-term consequences of spending decisions. “This is save now, prepare for later.”

The financial services industry aggressively lobbied Brown for a veto, warning that the proposal is built on shaky financial assumptions and may create overwhelming political pressure for taxpayers to bail it out if it hits hard times.

California lawmakers voted in 2012 to study the idea of creating a publicly run retirement plan for private-sector workers. After lawyers and financial analysts said the program was likely viable, the Legislature this year decided to implement the plan.

The move has been closely watched due to the $1 million California spent researching and refining its proposal and the state’s sheer size, with 12 percent of the U.S. population. Oregon and Illinois are working to implement similar programs, and studies have been ordered in several other states.

The U.S. Department of Labor gave the green light in August to retirement plans run by states and large cities or counties, putting to rest questions about their legality and removing a major hurdle.

California’s plan, SB1234 by Senate President Pro Tem Kevin de Leon, D-Los Angeles, requires employers that don’t offer retirement accounts to automatically enroll their employees in the state-run plan. Unless workers opt out, a percentage of their earnings would be deducted from each paycheck and held in lower-risk investments. The plans would stick with workers as they move from job to job, allowing them to accumulate larger balances in a single account.

Like a standard individual retirement account or 401(k), the investments would be subject to the ups and downs of financial markets, including the potential for losses.

Secure Choice, as the program is known, would be overseen by a board with authority to make decisions about investment options, the default savings rate and benefit payouts in retirement. Financial consultants recommended a default savings rate of 5 percent, which would rise by 1 percent a year until it reaches 10 percent of pay.

The cost to the state is unclear, as it depends how many employees participate, but it could reach up to $134 million over the first several years, according to the legislative analysis. The program is expected to eventually fund itself with fees on workers’ deposits.

But Paul Schott Stevens, president and CEO of the Investment Company Institute, which represents mutual funds and other investment products that comprise a large share of traditional retirement savings accounts, said in a letter to Brown that the program underestimates the risks and is based on unrealistically rosy assumptions about the rate of savings.

With so many financial pressures facing lower-income workers, many are likely to opt out or withdraw their balances early, he wrote, and the cost to administer millions of small accounts would be higher than proponents assume. Moreover, he said, the state’s obligations under securities law are uncertain, and the political pressure for taxpayers to backfill investment losses would be intense.

“It simply would be imprudent to move forward with the program without much further study and far greater assurance that its costs are fully understood and accounted for,” Stevens wrote.