Tunisian President Beji Caid Essebsi declared a 30-day state of emergency Saturday after a purported Islamic State terrorist massacred 38 people at a tourist beach resort last week.
Essebsi said in a television address to the nation that Tunisia was facing a "very serious danger."
He said the state of emergency was needed because of "the exceptional situation which the country is going through after the latest terrorist attack and the persistent threats which place the country in a special type of war."
For the next month, police and the army will have special powers to carry out raids at any moment on the homes of suspected terrorists and other criminals.
The government has also fired the governor of the Sousse region, where the beach resort is located, and several officials from the gunman's hometown.
The Islamic State group claimed responsibility for the June 26 attack, carried out by a gunman identified as Saif Rezgui. Thirty of the victims were British tourists. Others were from Belgium, Germany, Ireland, Portugal and Russia.
Police shot and killed Rezgui. But Tunisian Prime Minister Habib Essid said police were too slow in responding to the shootings.
Rezgui was the only shooter, but eight people are in custody, suspected of helping him plan the attack.
Islamic State extremists also said they were behind the March terrorist shooting at the Bardo museum in Tunis that killed 21 people.
Officials said Rezgui and the Bardo gunmen trained in Libya at the same time.