Companies are poised to install record amounts of batteries on America’s electric grid this year, as government mandates and a steep decline in costs fuel rapid growth in power storage.

The U.S., which had less than a gigawatt of large battery installations in 2020—roughly enough to power 350,000 homes for a handful of hours—is on pace to add six gigawatts this year and another nine gigawatts in 2022, according to S&P Global Market Intelligence.

Demand for utility-scale storage is expected to keep rising world-wide for the next several years, driven by rapid growth in the U.S. and China, as new storage technologies and pressure to add renewable energy sources to stem carbon emissions reshape the electricity industry.

Giant batteries, often paired with solar farms, can charge when sunshine is plentiful, then send electricity to the grid later when the sun goes down or demand otherwise spikes and power is more valuable. The installations, most of which currently use lithium-ion batteries like the ones found in electric vehicles and laptops, resemble rows of boxy shipping containers, and usually provide up to four hours of backup power.

The surge in battery development has the potential to substantially change the power generation sector. Electricity discharged from batteries is increasingly replacing electricity generated by gas-fired power plants in certain parts of the country, especially those that only fire up during periods of peak demand. Already, utilities, power generators and investors are rethinking the need for conventional power plants, as batteries become cheaper and more viable.

Plummeting costs for lithium-ion batteries, which have become ubiquitous in smartphones and laptops and are increasingly in high demand for electric vehicles, have made utility-sized battery projects more economical. Lithium-ion battery packs, which cost more than $1,200 per kilowatt-hour in 2010, have fallen to around $132 this year, according to data from BloombergNEF.

California is driving much of the U.S. battery market’s expansion. It is racing to secure power to make up for the impending closure of several gas-fired power plants as well as a nuclear facility that provides nearly 10% of the electricity generated in the state. A California law passed in 2018 requires the state to decarbonize its power grid by 2045.

At least eight other states so far have storage mandates or targets, including New York, Virginia and Nevada, according to the U.S. Energy Storage Association. Goldman Sachs expects the U.S. market for stationary batteries to grow from about $1 billion in 2020 to $13 billion to $14 billion by 2030.

Storage developer Key Capture Energy now has 370 megawatts of battery projects in operation or under construction, up from 54 megawatts this time last year. The company is working on projects in New York, New England, Texas and elsewhere, including a 20-megawatt installation on the site of a Maryland coal plant that is set to retire in the coming years.

Jeff Bishop, Key Capture’s co-founder and chief executive, said declining costs have enabled the company to expand to Oklahoma, Michigan and other states where it has historically been economically challenging to build batteries.

“Five years ago, most energy storage developers were small shops like us that had a couple of people and PowerPoints and dreams,” Mr. Bishop said. “Now, it’s companies with real money behind them and billions of dollars for growth.”

Some states that lack storage mandates have had a boom in battery installations anyway, including Arizona and Texas, where batteries are being built alongside large renewable energy projects, but also as stand-alone projects that aim to take advantage of fluctuations in power prices.

The major Texas grid operator had 225 megawatts of utility-scale battery storage operating at the end of 2020. Now one company, a subsidiary of Italy’s Enel ENEL 0.26% SpA, has 551 megawatts under construction in Texas. This month, it connected a 55 megawatt site to the grid southeast of Dallas.