Suspected Islamic gunmen attacked an upscale cafe in the Bangladeshi capital popular with foreigners before police stormed the building on Saturday and rescued at least 13 hostages, officials said.
Six gunmen were killed during the police operation and one was captured alive, Bangladesh Prime Minister Sheikh Hasina said in a TV broadcast. She said 13 hostages were rescued, but that police were unable to save all of them.
"The operation is over and the situation is under control," army spokesman Colonel Rashidul Hasan told Reuters.
The attack marks a major escalation in a campaign by Islamic militants over the past 18 months that had targeted mostly individuals advocating a secular or liberal approach in mostly Muslim Bangladesh.
The number and nationality of the hostages were unclear. Police said earlier the gunmen were holding about 20 hostages.
One Japanese man was among those rescued and taken to a Dhaka hospital with a gunshot wound, a Japanese government spokesman said. Italy's ambassador to Bangladesh, Mario Palma, told Italian state TV seven Italians were among the hostages.
Islamic State, which has claimed the attacks, posted photos of what it said were dead foreigners killed in the assault. Police said they believed about eight to nine gunmen had been holed up in the cafe, armed with assault rifles and grenades.
Gowher Rizvi, an adviser to Bangladesh Prime Minister Sheikh Hasina, told Reuters security forces had tried to negotiate with the gunmen.
Twenty customers in cafe
The hostage crisis began when security guards in the Gulshan district of Dhaka, popular with expatriates, noticed several gunmen outside a medical center, Rizvi said. When the guards approached, the gunmen ran into the Holey Artisan cafe, which was packed with people waiting for tables, he said.
Police said the assailants exchanged sporadic gunfire with police outside for several hours after the gunmen attacked the restaurant around 9 p.m. on Friday.
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 that killed at least two of them.
Television footage showed a number of police being led away from the site with blood on their faces and clothes.
Islamic State said 24 people had died. Bangladesh police denied that, saying the two police officers were killed and at least 20 people wounded.
A cafe employee who escaped told local television about 20 customers were in the restaurant at the time, most of them foreigners. Some 15 to 20 staff were working at the restaurant, the employee said.
The rescued Japanese man was eating dinner with seven other Japanese, all of whom were consultants for Japan's foreign aid agency, the Japanese government spokesman said. He did not know what happened to the others.
Spate of murders
The hostage crisis marks an escalation from a recent spate of murders claimed by Islamic State and al Qaeda on liberals, gays, foreigners and religious minorities, and could deal a major blow to the country's vital US$25 billion garment sector.
A Hindu priest was hacked to death on Friday at a temple in Jhinaidah district, 300 km southwest of Dhaka.
Both Islamic State and al Qaeda have claimed responsibility for many of the killings, although local authorities say no operational links exist between Bangladeshi militants and international jihadi networks.
Bangladesh security officials say two local militant groups, Ansar-al-Islam and Jamaat-ul-Mujahideen, have been behind the spate of violence over the past 18 months. Ansar pledges allegiance to al Qaeda, while Jamaat-ul-Mujahideen claims it represents Islamic State.
"The bottom line is Bangladesh has plenty of local, often unaffiliated, militants and radicals happy to stage attacks in ISIS's name," said Michael Kugelman, South Asia associate at The Wilson Centre in Washington D.C., using an acronym commonly used for Islamic State.
Islamic State had claimed more attacks in Bangladesh than in Pakistan or Afghanistan, he said.
The restaurant assault also comes after Bangladesh hanged an Islamist party leader, Motiur Rahman Nizami, on May 11 for genocide and other crimes committed during a 1971 war of independence from Pakistan. That has drawn an angry reaction and some scattered violence from supporters. Nizami, 73, was a former legislator and minister during opposition leader Khaleda Zia's last term as prime minister.
Foreign diplomats and human rights groups have warned that Bangladesh's ongoing war crime tribunals and the government's pressure on the Bangladesh Nationalist Party have created a backlash domestically, according to Brad Adams, Asia director at Human Rights Watch.
"They need to maintain legal political space for Jamaat and the BNP so that they don't drive people into the shadows and violence," Adams said in a telephone interview, cautioning that it's not known whether that dynamic and the bloodshed in Dhaka were related.