DHAKA (AFP) -- Gunmen stormed a crowded restaurant popular with foreigners in the Bangladeshi capital Dhaka on Friday night, taking dozens of people hostage and triggering a deadly firefight with police, witnesses and officials said.
The Islamic State group claimed responsibility for the attack on the Holey Artisan Bakery restaurant in Dhaka's upmarket Gulshan diplomatic quarter in which two police officers were killed.
Police said the men appeared to be Islamist militants.
Some diners managed to escape including an Argentine chef and a Bangladeshi man who took refuge in an adjacent building, but police said there were still a number of people being held inside the restaurant hours after the assault.
"Some people are being held at gunpoint," said Monirul Islam, chief of the police Counter Terrorism and Transnational Crime Unit.
Some managed to speak to relatives by phone, reporting there were up to 40 people trapped inside, around half of them foreigners, the private Ekattur TV station said.
Another told relatives he feared they would be killed if police tried to storm the restaurant to end the siege.
"He is very nervous," the man's nephew, who had spoken to him by phone, told AFP.
"He urged the police not to storm the restaurant, saying the gunmen will kill them."
The White House said US President Barack Obama had been briefed on the attack, a rare occurrence in an area of Dhaka considered relatively safe.
"We are trying to communicate with them (gunmen). We want to resolve it peacefully," the head of Bangladesh's elite security force Benazir Ahmed told reporters.
The restaurant's supervisor Sumon Reza who escaped by jumping from the roof told a local newspaper there were 20 foreigners being held hostage.
"I was in the roof. The whole building was shaking when they set off explosives," he said.
Bangladesh has been reeling from a wave of murders of foreigners, religious minorities and secular activists by suspected Islamist militants.
But those murders generally only involved a handful of assailants and the latest attack appears to have been on a much bigger scale and the first time that people were held hostage.
The IS-linked Aamaq news agency said the group was behind the attack and that "more than 20 people of different nationalities (were) killed".
Heavily armed police and paramilitary guards cordoned off the area after the gunfight broke out.
"Two police officers including the head of Banani police station were killed. It appeared they were hit by bullets and splinters from a grenade," deputy commissioner of Dhaka police Sheikh Nazmul Alam told AFP.
"Up to 20 police officers were injured. Seven-eight people have come out of the restaurant. But there are some people inside."Dhaka Police chief Asaduzzaman Miah said police were trying to establish contact with the hostage takers in a bid "to rescue everyone without any harm".
The attack took place near the Nordic Club, where expatriates gather, and the Qatari, Italian and Egyptian embassies as Bangladesh observes the Muslim holy month of Ramadan.
The French Ambassador Sophie Aubert said the restaurant was "very popular" among diplomats and other foreigners in Dhaka.
"We're very concerned that there are some hostages inside," she told AFP, adding she was trying to confirm whether there were foreigners inside.
It follows a series of killings targeting foreigners in Bangladesh that have been claimed by the Islamic State group.
Earlier Friday a Hindu temple worker was hacked to death in western Bangladesh.
Police also shot dead two Islamist students suspected in last month's murder of a Hindu priest and arrested a top Islamist militant who masterminded an attack on a Hindu lecturer last month.
The government and police blame homegrown militants for the killings, which they say are part of a plot to destabilize the country.
They have blamed the main opposition Bangladesh Nationalist Party and its Islamist ally.
Last month authorities launched a nationwide crackdown on local jihadist groups, arresting more than 11,000 people, under pressure to act on the spate of killings.
But many rights groups allege the arrests were arbitrary or were a way to silence political opponents of the government.
Experts say a government crackdown on opponents, including a ban on the country's largest Islamist party following a protracted political crisis, has pushed many towards extremism.