SACRAMENTO — In a major environmental milestone, Gov. Jerry Brown on Monday signed a law requiring California to obtain 100 percent of its electricity from clean sources such as solar, wind and hydropower by 2045.

The new law keeps California at the forefront of addressing climate change and essentially commits the world’s fifth-largest economy with 40 million people to a phase-out of fossil fuels from power plants. It also requires that 50 percent of the state’s electricity come from renewable energy by 2026 and 60 percent by 2030, up from the current level of 32 percent.

At a ceremony in the state Capitol, Brown signed SB 100, by State Sen. Kevin de León, D-Los Angeles. The new law gives California the most far-reaching clean energy goals of any U.S. state, along with Hawaii, which set a similar target in 2015 of 100 percent carbon-free electricity by 2045.

“It will not be easy. It will not be immediate. But it must be done,” Brown said.

Brown’s action comes as thousands of scientists, political leaders, celebrities and others are arriving in San Francisco this week for the “Global Climate Action Summit,” a meeting at the Moscone Center that is spearheaded by Brown and United Nations officials. The summit aims to secure commitments from cities, states, provinces, countries and corporations to reduce greenhouse gases that the world’s leading scientific organizations say are trapping heat in the atmosphere and warming the planet.

The new law also marks the latest and perhaps most high-profile push back by California on environmental issues against the White House. President Trump has denied climate science, begun steps to withdraw the United States from the 2015 Paris climate agreement, and worked to expand the use of coal, one of the most polluting fuels.

Environmentalists cheered the news Monday. They said the new law will reduce smog and set a benchmark that other states and countries are expected to copy.

“A child born this week in California can count on reaching adulthood in a state free of smokestacks to create electricity,” said Kathryn Phillips, director of Sierra Club California.

“I feel so proud to be a Californian right now. And I feel so proud of people all over America who have kept fighting to clean up climate pollution, despite the federal government’s abandonment. This win, this bill, is for them, too.”

Supporters of the measure included most of the state’s leading environmental groups and renewable energy trade associations, along with the American Lung Association, the American Academy of Pediatrics, the League of Women Voters and business groups, including the Silicon Valley Leadership Council, Adobe, Nike, Gap Inc., and Levi Strauss.

Opponents included major utilities, such as Pacific Gas and Electric and Southern California Edison, oil interests such as the Western States Petroleum Association, and the California Farm Bureau Federation and California Chamber of Commerce.

Critics said that the bill would bring higher electricity prices.

“We’ve reached all these great goals with renewables, but at the same time our families have paid the price with an increase in their electric bills every year,” said Devon Mathis, R-Visalia, during the Assembly debate.

PG&E echoed that concern Monday.

“If it’s not affordable, it’s not sustainable,” the utility said in a statement. “We believe customers must be protected from unreasonable rate and bill impacts.”

Opponents also noted that transportation — mostly gasoline and diesel fuel burned by cars and trucks — generates 41 percent of the state’s greenhouse gas emissions, more than double the 16 percent that power plants produce.

The bill passed the state Assembly by a vote of 44-33 and the state Senate 25-13 late last month. Nearly every yes vote came from Democrats. The only Republican to vote yes was Assemblywoman Catharine Baker, R-San Ramon. In the week of the final vote, former Republican Gov. Arnold Schwarzenegger wrote a letter of support.

“California must take a stand and tell the world we are, as always, undeterred by those who wish to stop our progress and move backwards,” Schwarzenegger wrote. “We continue to move forward, and passing SB 100 is one of the boldest moves we can make to help save our climate and way of life.”

Californians overall seem to favor the law. In a poll in July by the Public Policy Institute of California, a nonpartisan research organization, 67 percent of likely voters said they favored the 100 percent clean energy measure, and 21 percent opposed it.

The law is the culmination of a movement that began 16 years ago, when former Gov. Gray Davis signed the first “renewable portfolio standard,” by former Palo Alto state senator Byron Sher. The renewable standard required 20 percent of the state’s electricity to come from renewable sources. Lawmakers ratcheted that target up several times, leading to the construction of massive new solar farms and expanded wind facilities.

More efficient technology and larger projects have helped bring down the costs of green energy. Between 2008 and 2015, the price utilities paid for solar energy dropped 77 percent. And the prices of wind contracts have gone down 47 percent over the same general time period, according to the California Public Utilities Commission.

Tom Steyer, a billionaire businessman and former San Francisco hedge fund manager, said wind and solar prices per kilowatt-hour are falling to where they are often cheaper than natural gas-fired electricity. Technological advances such as improved battery storage will only continue to lower the costs of clean energy, he said.

“The idea that somehow Americans and Californians are going to get stupid and we’re going to forget how to innovate and the technology’s not going to increasingly drive costs down is crazy,” Steyer said in an interview. “Of course it is.”

Meanwhile, pollution is falling. Since 2004, as renewable energy has boomed, California’s greenhouse gas emissions have dropped by 13 percent, even as the economy has grown by 26 percent over the same time.

The new law makes a key change. To deal with significant problems — namely the need to keep a steady supply of electricity even at night when the sun isn’t shining and during times when the wind isn’t blowing — the previous laws defined renewable energy to include not only solar and wind but also geothermal energy, biomass and hydroelectric power from small dams.

Monday’s law goes further, saying the last 40 percent of the 100 percent total can come from “carbon-free” sources, including large dams, nuclear power and even natural gas-fired power plants, if they can capture and store the carbon in the ground, which so far is an unproven technology. California has only one nuclear power plant, Diablo Canyon in San Luis Obispo County, and its owner, PG&E, has announced it will close by 2025.

Steyer was less certain about whether nuclear power — which does not produce climate-warming greenhouse gases — would see a comeback as a result of California’s ambitious new goals.

“They have a waste issue, which is real, they have a safety issue, which is real, and they have a cost issue that is real,” he said. “They have huge, difficult engineering challenges that are not trivial, but if they can overcome them, fantastic.”