TUNIS — Speaking on national television, President Beji Caid Essebsi declared a state of emergency in Tunisia on Saturday, eight days after a terrorist attack killed more than 30 foreign tourists.

“Tunisia, which is dear to all of us, is going through difficult circumstances, exceptional circumstances, that necessitate exceptional measures to face them and prevent a worse situation,” Mr. Essebsi said.

“Our security forces are in a full alert status, but we do have weaknesses as our prime minister admitted,” he said. “We are not blaming anyone, but we are calling for everyone to feel and act responsibly. If such incidents happen again, the state will collapse. It is the duty of the president to take a stance.”

The state of emergency will last 30 days and can be renewed, he added. The measure increases the powers of the security services and restricts the right of assembly. The army in particular will be allowed to expand the areas in which it can operate.