The declaration gives the military and police more authority to combat terrorism and places restrictions on such rights as public assembly. Essebsi pledged to respect freedom of expression.
In a televised address to the nation, the President mentioned the terror group ISIS by name and declared Tunisia at war with extremism.
"Tunisia faces a very serious danger and it should take any possible measures to maintain security and safety," he said.
The decision comes in response to the June 26 attack
in which a gunman opened fire at the beachfront Hotel Riu Imperial Marhaba in the coastal city of Sousse. At least 38 more were killed in the attack, for which ISIS has claimed responsibility.
"Terrorism is spreading," Essebsi said. "I believe, and I say this plainly and clearly. If this were to happen, which happened in Sousse. If this were to happen again, the country would collapse."
ISIS has claimed responsibility for the attack, but it is unclear whether the Islamist group had any direct role in it.
The terror group posted a photo of the alleged attacker, whom Tunisian authorities have identified as Saif Al-Deen Al Rezgui, 24, from the town of Gaafour, about 160 kilometers (100 miles) northeast of Sousse.
Police shot Al Rezgui dead near the beach the day of the attack.
Interior Minister Mohamed Najem Gharsalli announced an initial round of arrests on Monday of what he said was "a first group, the important part of the network that was behind this terrorist criminal."
Al Rezgui trained with the people who carried out the attack on the Bardo Museum in Tunis in March, Rafik Chelli, Tunisia's secretary of state for national security, told CNN last week.
In an online audio statement, ISIS claimed responsibility for the Bardo Museum attack and identified two men, Abu Zakariya al-Tunisi and Abu Anas al-Tunisi, as having carried it out. CNN could not independently verify the legitimacy of the audio claim.
On Saturday, the Tunisian anti-terrorism unit surrounded the house of Hasan alRubai, also known as Hasan Ma'eez, who was allegedly involved in a number of offenses, including drug trading, smuggling, terrorism and the Bardo Museum attack, according to the interior ministry and the state news agency. The suspect committed suicide by shooting himself in the head, officials said.
A pistol, ammunition, a hand grenade and three cars -- including an ambulance -- were confiscated from his house in the southeastern city of Ben Guerdane, according to the interior ministry and the state news agency.
"Now, we are on a state of war," Essebsi said."We have to confront this with what is necessary to fight a war. Undoubtedly, in a way, the armed forces have a role, and they have to be on a state of alert. The national guard, the police. But this war is special."
The victims of the attacks came from various nations, including Britain, Germany, Russia and Ireland. But Britain suffered the heaviest loss.
Thirty of the people killed in the beach massacre are UK citizens, authorities said, marking the worst terror attacks against Britons in a decade.
The gun rampage is the most significant attack against British citizens since the London transport bombings 10 years ago, in which 52 people were killed and hundreds injured.
Tunisia's tourism industry had been beginning to recover since the 2011 Arab Spring, but the killings in Sousse and the deadly attack, three months before, on the Bardo Museum in Tunis could mean tough times ahead
In March 2014, Tunisia lifted a state of emergency that had been in effect since the 2011 revolution in the country, the cradle of the Arab Spring grassroots movement that toppled autocratic leaders and promoted freedom and democracy across the Arabic-speaking region in North Africa and the Middle East.