Southern California Edison’s struggles after the closing of a key natural gas reservoir following a massive leak last year has led it to none other than electric car maker Tesla.

Tesla on Thursday announced that it had won a deal to provide 20 megawatts of batteries to the utility to plug into one of its substations and provide energy during peak grid times. Tesla says the large battery installation would be able to provide enough power for 2,500 homes daily or 1,000 Tesla cars.

Southern California Edison has been adding both energy storage and energy efficiency measures following the gas leak last year at Aliso Canyon, near Los Angeles that forced neighborhoods to evacuate. Aliso Canyon provided fuel to natural gas power plants that generated energy during peak grid times (called peaker power plants), like hot summer afternoons when homes and offices crank up the air conditioning.

Without fuel for these peaker power plants, the utility is worried about blackouts during times of high energy use. California Governor Jerry Brown even issued a state of emergency and California’s regulators mandated that the utility add energy storage as quickly as possible.

For an inside look at Tesla’s Gigafactory watch our video.

That’s why the utility is rapidly turning to Tesla TSLA , but also Alphabet’s Nest GOOG , and others. The utility is also looking to pair batteries with solar projects as it adds clean power to meet state mandates.

California is a major market for these types of large grid-connected battery projects. State regulators have called for 1.3 gigawatts (1,300 megawatts) of batteries for the grid by 2020. Southern California Edison had already planned to install 250 megawatts of batteries in its territory before the Aliso Canyon leak.

AES Energy Storage plans to build 37.5 megawatts of batteries for utility San Diego Gas & Electric and 100 megawatt of batteries for Southern California Edison at the Alamitos Power Center in Long Beach, Calif., to replace a peaker power plant. A startup called Advanced Microgrid Solutions is building an additional 50 megawatts of batteries, some of them from Tesla batteries, for Southern California Edison.

Get Data Sheet, Fortune’s technology newsletter.

Tesla packages lithium-ion batteries, made by Panasonic—the same ones it uses in its electric cars—into battery packs that can be operated by software that decides when the batteries charge and discharge. Last year, Tesla announced that it would start selling these battery packs, called Powerpacks, to utilities, building owners, and even home owners.

Tesla started assembling small numbers of these Powerpacks last year at its massive battery factory, called the Gigafactory, which is under construction outside of Reno, Nev. Eventually, it will use batteries that are made on site.

Tesla’s Powerpacks for Southern California Edison will charge up during times of low energy use, like during the night, and will be able to provide energy on-demand during high peak times like a hot afternoon.

Tesla is providing Powerpacks to plug into buildings, too, like offices and malls.