Researchers have designed a lithium-ion battery that contains a fire-extinguishing material, which is released if the battery gets too hot.
Flame retardant triphenyl phosphate (TPP) sits inside a shell within the electrolyte fluid. The shell melts when the temperature reaches 150C, releasing the chemical compound.
In tests, battery fires were extinguished in 0.4 seconds, informs BBC.
Lithium-ion batteries power many devices but are a known fire hazard.
The Stanford University research team's peer-reviewed paper has been published by the journal Science Advances.
Previous attempts to incorporate TPP inside batteries without the shell have hampered their performance.
If a lithium-ion battery cell charges too quickly or a tiny manufacturing error slips through the net it can result in a short circuit - which can lead to fire.
In February 2016, the US National Transportation Safety Board issued a warning about lithium batteries in aeroplane cargo, describing them as "a fire and explosion ignition source".
While Samsung has not yet released the results of its investigation into what caused some of its Galaxy Note 7 smartphones to catch fire last year, local reports have suggested it has found that the batteries were responsible.
However, the firm would not confirm that this was their conclusion.