"During sea trials of a nuclear-powered submarine of the Pacific Fleet the firefighting system went off unsanctioned, killing over 20 people, including servicemen and workers," Igor Dygalo, a Russian Pacific Fleet spokesman, said.
"The submarine is not damaged, its reactor works as normal, and radiation levels on the submarine are normal," Dygalo said.
The Russian prosecutor-general's office said in a statement that a poisonous fire suppressant designed to starve a fire of oxygen had caused the deaths.
"Results of a preliminary investigation show that deaths occurred as a result of freon gas entering the lungs," the office said.
It was unclear what activated the fire-extinguishing system, or why the portable breathing gear usually issued to Russian submarine crews did not save the men on board.
The submarine, whose name and whereabouts have not been disclosed, was ordered to return to port after the accident.
Vera Sanzhonova, wife of one of the men on board the submarine at the time of the accident, said she had driven to the naval base where the vessel was moored for information on her husband.
"I have not received any news. My husband is neither on the list of those injured nor among the dead," she told Reuters at Bolshoi Kamen base.
"I've been driving here all the way down from Vladivostok, shedding tears and swallowing pills."
Dmitry Medvedev, the Russian president, has ordered a "full and meticulous" investigation and "all possible aid and support to the victims' families," according to Russia media reports.
Russia's worst submarine disaster occurred in August 2000, when the nuclear-powered Kursk sank in the Barents Sea, 118 people on board died in the incident.