DHAKA: Militants killed 20 hostages, mostly foreigners, many of them hacked to death, after taking them hostage in a Bangladesh cafe overnight, an army spokesman said on Saturday.

“We've recovered 20 bodies. Most of them had been brutally hacked to death with sharp weapons,” Brigadier General Nayeem Ashfaq Chowdhury told reporters in Dhaka.

The military said 20 hostages were killed during the 10-hour standoff, and a survivor's father said the attackers spared people who could recite verses from the Quran.

Dhaka's diplomatic zone on map.— AFP

An elite police force stormed the cafe to end the siege on Saturday, rescuing 13 people including one Japanese and two Sri Lankans.

Six gunmen were killed during the police operation and one was captured, Prime Minister Sheikh Hasina said in a TV broadcast.

Italy's foreign minister says the bodies of nine Italians have been identified in the Dhaka restaurant attack by extremists and one Italian citizen is unaccounted for.

Foreign Minister Paolo Gentiloni says Saturday that the person isn't among the bodies identified in a military morgue in Dhaka and isn't among the 20 victims.

Seven Japanese citizens have also been confirmed dead in the attack, Japanese Chief Cabinet Secretary Yoshihide Suga said.

There are reports that two Bangladeshi citizens along with two local security officials were also killed in the attack.

Gunmen attacked the upscale cafe, popular with expatriates, in the diplomatic area of Dhaka at around 9pm on Friday and had been holding about 20 hostages, including foreigners, before police poured into the building to try to free those stuck inside. At least two police were killed, authorities said.

“The operation is over. The situation is completely under control,” army spokesman Colonel Rashidul Hasan told AFP.

Mizanur Rahman Bhuiyan, a deputy director at the RAB force told Reuters one foreigner, probably Japanese, was among those who escaped after more than 100 commandos launched an operation to secure the upmarket cafe.

The militant Islamic State (IS), which has claimed the attacks, posted photos of what it said were dead foreigners killed in the assault on the cafe.

Security personnel are seen near the Holey Artisan restaurant hostage site, in Dhaka, Bangladesh, July 2, 2016.— Reuters

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

Italian, Indian hostages

The assailants exchanged sporadic gunfire with police outside for several hours after the attack but no gunshots had been heard from inside the restaurant since late Friday night.

Italian and Indian nationals were among the hostages, said a duty officer at RAB's control room. Italy's ambassador to Bangladesh, Mario Palma, told Italian state TV seven Italians were among the hostages.

Bangladeshi soldiers and security personnel sit on top of armored vehicles as they cordon off an area near the sieged restaurant.— AP

The hostage crisis marked an escalation from a recent spate of murders claimed by IS and Al Qaeda on liberals, gays, foreigners and religious minorities, and could deal a major blow to the country's vital $25 billion garment sector.

Nearly two dozen atheist writers, publishers, members of religious minorities, social activists and foreign aid workers have been slain in Bangladesh since 2013 by attackers. The frequency of attacks has increased in recent months.

On Friday, a Hindu temple worker was hacked to death by at least three assailants in southwest Bangladesh. The attacks have raised fears that religious extremists are gaining a foothold in the country, despite its traditions of secularism and tolerance.

Sporadic gunfire, chaos

Rizvi, the Bangladesh prime minister's adviser, said 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 added.

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 around 25 people. Some 15 to 20 staff were working at the restaurant 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 met a hail of bullets and grenades.

Television footage showed a number of police being led away from the site with blood on their faces and clothes. Heavily armed officers were seen milling on the street outside.

The US State Department said all Americans working at the US mission there had been accounted for.

‘All Pakistanis safe and accounted for’

Foreign Office Spokesperson Nafees Zakaria said all Pakistani diplomats and their families in Dhaka were safe.

He added that Pakistani diplomatic staff has restricted their movement following the attack.

“We have confirmed that there is no Pakistan national among the hostages,” Zakaria added.