The footage was captured on a CCTV camera in Boots in the Leeds Trinity shopping centre.
Sparks can be seen shooting from the man's pocket as spare lithium-ion batteries burst into flame.
West Yorkshire Fire Service said the batteries were loose in the man's pocket and a short circuit may have been caused when one of them came into contact with another metal item in his pocket, possibly keys or coins.
The other possibility was that the two batteries shorted on one another.
The man was left with slight injuries and needed first aid treatment.
Fire investigator Jamie Lister said: “This footage clearly shows the dangers of storing batteries alongside any metal objects, be it keys, coins, or even your phone if it has a metal case.
“This is not the first time we have seen injuries caused by a lithium-ion battery exploding whilst being carried in someone’s pocket. We really want the public to understand the risks which can be easily avoided.
“There does not need to be a fault with the battery, the problem is the incorrect storage of the batteries.”
Mr Lister said there had been a marked increase in the number of fires attributable to the incorrect storage of batteries.
He said: “The use of rechargeable lithium-ion batteries is now commonplace in modern society and that’s why we want people to be vigilant because a simple mistake could have a devastating consequence.”
There was not a fault in the lithium-ion battery, the accident happened because the ends of the battery (terminals) were exposed and came into contact with another metal object and caused a short circuit.
Mr Lister warned against ever using damage batteries and advised using a plastic battery storage case.