Gunmen stormed a restaurant popular with expatriates in the diplomatic quarter of the Bangladeshi capital of Dhaka on Friday night and took around 20 people hostage, including several foreigners.
Two police officers were killed in the gun battle between law enforcement and gunmen.
Italian and Indian nationals are among the hostages, said a duty officer at the Rapid Action Battalion's (RAB) control room, adding that gun battles had stopped.
Bangladesh TV stations reported that the attackers entered the Holey Artisan Bakery in Dhaka's Gulshan area around 9:20 p.m. Friday and were holding customers and staff hostage.
The Daesh terrorist group later claimed responsibility for the attack via the group's Amaq news agency.
Amaq also said 24 people had been killed and 40 injured, some of them foreigners, in the attack.
Bangladeshi police, however, reported that only two police had been shot dead and at least 15 people were injured and said they were trying to free the hostages peacefully.
TV reports say a huge contingent of security guards cordoned off the area and the restaurant as they traded gunfire with the attackers who set off explosions.
Jamuna Television reported, quoting a kitchen staff worker at the restaurant who escaped the attack, said that the gunmen chanted "Allahu Akbar" (God Is Great) as they launched the attack.
Bangladesh has seen an increase in militant violence in the last year-and-a-half, with a series of deadly attacks targeting atheists, gays, liberals, foreigners and members of religious minorities in the mostly Muslim country of 160 million people.
The violence has tended to be assaults on individuals, often using machetes, and the raid on the restaurant was a rare instance of a more coordinated operation.
Both Daesh and al Qaeda have claimed responsibility for many of the killings, although local authorities say there are no operational links between Bangladeshi militants and international terrorist networks.