CAIRO — Gunmen in military uniforms killed 19 people on Wednesday in a midday attack on a museum in downtown Tunis, dealing a new blow to the tourist industry that is vital to Tunisia as it struggles to consolidate the only transition to democracy after the Arab Spring revolts.

Tunisian officials had initially said that the attackers took 10 hostages and killed nine people, including seven foreign visitors and two Tunisians. When security forces retook the museum about four hours later, however, the death toll more than doubled, raising questions about how and at what point the hostages had died.

Prime Minister Habib Essid said in a news conference that security forces had killed two gunmen inside the museum but that two or three accomplices might still be at large. He said 17 foreign visitors — including Polish, Italian, Spanish and German tourists — as well as two Tunisians, one of whom was a member of the security forces, had been killed in the attack. At least 22 others were wounded.