Tunisia's Prime Minister Habib Essid has said that 19 people were killed in the Tunis museum attack, including 17 tourists from Italy, Germany, Poland and Spain and Tunisians.
Two gunmen, who were wearing military fatigues, were also killed in the attack at the Bardo Museum, which shares its grounds with the country's parliament buildings. Essid also reported 24 wounded and said that two or three gunmen involved in the attack may still be at large.
The casualties also include a Tunisian policeman and cleaning lady.
"This is the work of cowards. We are have to join the efforts to fight terrorism. These wanted to harm," the country's prime minister said. "It is a critical moment in our history, and a defining moment for our future."
Parliament has been evacuated and the operation was reported to be over.
The company Costa Cruises has contacted Italian and Tunisian authorities because passengers of one of its ships was visiting Tunisia at the time of the attack, Spanish news agency Efe reported. According to company figures, there were 3,161 passengers on the ship Costa Fascinosa.
Pictures on social media purportedly taken by hostages seem to show up to 30 hostages gathered in the museum.
Special forces were deployed to storm the museum, and casualties have been taken to the hospital Charles Nicolle.
Footage on Tunisian television shows hostages fleeing the museum, given cover by Tunisian special forces.
Tunisian armed forces are fighting Islamist groups which emerged after the country's 2011 revolution, with thousands of Tunisians believed to have left the country to fight for Islamist groups in Syria and Iraq.
"The attack marks a new form of escalation for terrorist attacks in Tunisia. This is especially true given the fact that this attack was on a key landmark, which is just a stone's throw from the Tunisian Parliament," Imad Mesdoua, a political analyst specialising in Maghreb (North Africa), told IBTimes UK.
"It strikes at the heart of the Tunisian capital. The Bardo museum and the National Assembly are just a few metres from one another. It's the centre of power in Tunisia. All key government institutions are there. The Bardo museum is also a tourist landmark and Tunisia depends significantly on tourism industry for economic stability."
Tunisia has been a major source of Islamist fighters travelling to Syria since 2011; of the estimated 5,000 operating in the region, a few hundred have returned home.
The country is facing the menace posed by weapons smuggling through official border-crossing points with Libya. Earlier in March, Tunisian security forces, which now fear a cross-border spill, uncovered a series of arms caches near the south-east border with Libya, close to the city of Ben Guerdane.
It also struggles with the domestic threat coming from jihadists who are already on the territory – such as radical Salafist group Ansar al-Sharia and its member group Uqba Bin Nafe, which operates in the Chaambi Mountains near the Algerian border, the main hotbed of militant activity.
In his view, Tunisia has to step up its efforts because "the nature of the threat has grown substantially and traditional methods or weapons are not going to be suitable to match the threat".