Twenty foreign hostages have been killed at a cafe in the Bangladeshi capital, the army has said, in an attack claimed by the Islamic State of Iraq and the Levant (ISIL) group that ended after a 10-hour siege when commandos stormed the building.

Nine Italians, an American, seven Japanese and an Indian were confirmed on Saturday to be among the dead.

"Most [of] them had been brutally hacked to death with sharp weapons," army spokesman Brigadier General Nayeem Ashfaq Chowdhury said on Saturday.

Italy's foreign minister said on Saturday that one more Italian citizen was still unaccounted for.

He "could be hiding himself or could be among wounded people ... we are looking for him," Paolo Gentiloni, the Italian foreign minister, said.

Prime Minister Sheikh Hasina earlier said that 13 hostages had been rescued. Hasina said six gunmen had been killed and one captured in the early morning operation at the Holey Artisan Bakery, a cafe in Dhaka.

The rescued included two Sri Lankans and a Japanese citizen who was wounded, Lieutenant Colonel Tuhin Mohammad Masud said, adding there were casualties among the other hostages.

Bangladesh declared two days of national mourning following the attack.

IN PICTURES: Hostage drama in Bangladesh

"We have gunned down at least six terrorists and the main building is cleared," Masud told the Associated Press news agency.

Al Jazeera's Tanvir Chowdhury, reporting from Dhaka, said that the cafe was located in one of the most heavily policed parts of the capital, home to several embassies and popular with foreigners.

"In order to get in here you have to pass through a lot of police checkpoints. It's a highly cordoned-off area," Chowdhury said.

"So there's going to be a serious question raised: How did they manage to get in there with arms and ammunition, possibly even bombs and hand grenades?"

'Dead foreigners'

The crisis began at about 9pm local time, police said, when a group of gunmen burst into the cafe, which is popular with foreigners, young people, and middle class Bangladeshis.

During the siege, ISIL posted photos of what it said were dead foreigners in the cafe, where police believed the gunmen were holed up armed with assault rifles and grenades.

According to Rezaul Karim, the father of a witness, Hasnat, the gunmen asked everyone inside to recite from the Quran - the Islamic holy book.

"Those who recited were spared. The gunmen even gave them meals last night," he said. The others, he said, "were tortured".

Gowher Rizvi, an adviser to Prime Minister Hasina, told the Reuters news agency that security forces had initially tried to negotiate a way out of the crisis.

WATCH: Does Bangladesh have an ISIL problem?

Violence has spiked in Bangladesh in the past 18 months with a spate of attacks, often using machetes, against individuals including liberals, gays, foreigners and members of religious minorities.

ISIL, which is also known as ISIS, and al-Qaeda claimed many of those killings but the government denied their involvement and instead pointed the finger at local groups. "The Bangladesh government continues to deny that ISIL could have any connection or presence in Bangladesh, so if ISIL wants to make a statement that 'we are in Bangladesh and are with influence and impact' then this is probably their perfect opportunity," Talha Ahmed, a commentator on Bangladeshi affairs, told Al Jazeera. Earlier on Friday, a Hindu priest was hacked to death at a temple in Jhinaidah district, 300km southwest of Dhaka.

READ MORE: Extremism and a shrinking space for dissent

Rizvi said that the hostage crisis began when local security guards in the diplomatic enclave noticed several gunmen outside a medical centre.

When the guards approached, the gunmen ran into the restaurant, which was packed with people waiting for tables, he said.

An employee who escaped told local television about 20 customers were in the restaurant at the time, most of them foreigners. The restaurant has a seating capacity of about 25 people.

Some 15 to 20 staff were working there at the time, the employee said.

A police officer at the scene said that when security forces tried to enter the premises at the beginning of the siege they were met with a hail of bullets and grenades.

Television footage showed a number of police being quickly led away from the site by police with blood spattered on their faces and clothes.