A global wave of investment in high-capacity batteries is poised to transform the market for renewable energy in coming years, making it more practical and affordable to store wind and solar power and deploy it when needed.

Government-owned utilities and companies are buying batteries that can be larger than shipping containers. A configuration of Tesla Inc.’s new utility-scale batteries can hold enough energy to power every home in San Francisco for six hours. Battery makers also are working on more advanced models that will hold more power and last longer.

In the U.S., the Silicon Valley-based firm last month introduced its new battery technology called Megapack that Pacific Gas & Electric Co. plans to use in California. Mitsubishi Hitachi Power Systems is developing high-capacity batteries for a 1,000-megawatt venture in Utah that it touts as the world’s largest renewable-energy storage project.

In the U.K., ScottishPower is spending $7.2 billion on renewable energy, grid upgrades and battery storage between 2018 and 2022. The utility owns Scotland’s largest electricity network and operates in Europe’s windiest region, and generates all its power from renewable sources after selling its last fossil fuel assets in January.

China’s goal is to increase the use of renewable energy and batteries by 2030 as part of a massive national energy overhaul aimed at helping to reduce the use of polluting coal-fired power plants.