Tunisia's president has vowed to fight terrorism "without mercy", following a gun attack on the Bardo Museum in the capital Tunis that killed 19 people.
Seventeen tourists were killed in the attack, including visitors from Japan, Italy, Colombia, Australia, France, Poland and Spain, officials said.
Two Tunisians, one a police officer, were also killed in Wednesday's attack.
Security forces have killed two gunmen but are continuing the search for accomplices.
Officials say that more than 40 people, including tourists and Tunisians, were injured.
'Democracy will win'
President Beji Caid Essebsi said the country was "in a war with terror".
"These monstrous minorities do not frighten us," he said in remarks broadcast on national TV. "We will resist them until the deepest end without mercy.
"Democracy will win and it will survive."
Prime Minister Habib Essid said: "It is a critical moment in our history, and a defining moment for our future."
At the time of the attack, deputies in the neighbouring parliamentary building were discussing anti-terrorism legislation.
Parliament was evacuated, but later reconvened for an extraordinary session in the evening.
Many Tunisians took to the streets of central Tunis to protest against the attack, waving flags and lighting candles outside the museum.
World leaders condemned the attack and expressed their support for Tunisia's counter-terrorism efforts.
A spokesman for UN Secretary-General Ban Ki-moon said Mr Ban "condemns in the strongest terms today's attack... and deplores the loss of life".
Meanwhile, White House spokesman Josh Earnest said the US would "continue to stand with our Tunisian partners against terrorist violence".
EU foreign policy chief Federica Mogherini offered her condolences (in French) to the victims' families, and said the EU would "fully support Tunisia in the fight against terrorism".
The attack is a huge blow for Tunisia's tourism industry and its government, which only emerged at the end of a long political transition several months ago, the BBC's Arab affairs editor Sebastian Usher says.
Islamist militants have tried to derail the democratic transition, which, although fragile, remains the most positive result of the Arab Spring in the Middle East, our correspondent adds.
Tourism is a key sector of Tunisia's economy, with large numbers of Europeans visiting the country's resorts.
In 2002, 19 people, including 11 German tourists, were killed in a bomb blast at a synagogue in the resort of Djerba. Al-Qaeda said it had carried out that attack.
Concerns about security in Tunisia have increased in recent months as neighbouring Libya has become increasingly unstable.
A large number of Tunisians have also left to fight in Syria and Iraq, triggering worries that returning militants could carry out attacks at home.
Source: BBC