DETROIT, June 10 -- General Motors spent years and billions building the capacity to make batteries for electric cars. The cars have not sold as fast as the bet required. So the company is doing the only thing that makes sense with a factory full of cells and not enough vehicles to put them in: it is selling the batteries to something that cannot get enough of them, the electricity grid.

The plan, which GM laid out this week, turns a problem into a product. Demand for grid-scale energy storage is now outrunning demand for EV batteries, the company says, and it intends to supply both businesses and the power system itself with stationary battery packs. It is repurposing production it had built for vehicles, using its Ultium Cells joint ve...