In an unprecedented turn of events last night, gunmen held hostage dozens of people inside a popular hangout for foreigners in the capital's diplomatic zone of Gulshan, and fired shots and hurled bombs at law enforcers, killing at least two cops and injuring around 40.

According to some accounts, 20 foreigners and a few children were among the hostages.

The hostage crisis, the first-ever such incident in the country, began around 8:30pm after seven to eight men carrying firearms, bombs and swords stormed the building in the posh neighbourhood.

As the law enforcers in groups tried to close in on, the gunmen opened fire and blasted bombs, sending a wave of panic in the high-security area.

The strike left Rabiul Islam, assistant commissioner of the Detective Branch of Police, and Salauddin Khan, officer-in-charge of Banani Police Station, wounded. Both the officials died at the United Hospital.

Dozens of the injured, mostly law enforcers, were taken to different hospitals, including Dhaka Medical College Hospital.

Global terror outfit Islamic State has claimed credit for the attack, said the Site Intelligence Group, citing pro-IS Amaq News Agency. The Daily Star, however, could not independently verify the statement.

The US State Department said it appears to be a hostage situation, and the White House said US President Barack Obama was following the situation, reports AFP.

The incident prompted the US, the UK and Australia to issue travel alert for their citizens living in Bangladesh.

The building by the Gulshan lake and on Road 79 houses two restaurants -- Holey Artisan Bakery on the ground floor and O Kitchen on the first.

Talking to The Daily Star, Sumon Reza, superviser of O Kitchen, said he saw seven to eight armed men aged between 20 and 28 inside the restaurant.

"Two of them had arms in their hands while another was carrying a sword," said Sumon, who managed to escape the restaurant through the roof.

At that time, around 20 foreigners and seven to eight Bangladeshis were having dinner, he said, adding that around 40 staff members were at work.

"The gunmen fired blank shots and detonated several crude bombs causing huge panic among those in the restaurant. Some of the diners ducked under the table and some lay on the floor," he said.

"They shouted “Allahu Akbar” before blasting bombs,” he said.

After some time, they held the main chef hostage and fired a shot that grazed his face, leaving him slightly injured.

Amid confusion and horror, seven to eight of the restaurant staffs ran to the roof and managed to escape.

Residents of the area said they heard sounds of gunshots and screams of people from inside the restaurant.

At 10:07pm, a diplomat via SMS told The Daily Star that he could hear gunfire and that the situation looked quite worrisome. “Fire exchanges took place reportedly between police and terrorists….”

He again said at 10:35pm, “My info source said to me that about 20-30 people are there as hostage by 5-6 gun fighters.”

He further informed at 12:02am that “Italians and Japanese are there.”

Another diplomat at 10:20pm said, “I heard some 20 foreigners were being held hostage. One Japanese is among them.”

“No idea about the exact number of foreigners. We guess there would be 10-20 people,” another diplomat said at 12:07am.

A source at the US embassy at 12:44am said, “So far no American is there. Total number could be 20.”

Around 11:15pm, Rab Director General Benazir Ahmed talked to the media.

"We are primarily trying to establish contacts with the attackers, who are holding clients hostage. We have to try to save every hostage … Every life is precious," he said and urged the media not to broadcast the incident live.

"Live broadcast may hamper the operations and endanger public security,” he told the journalists present there.

Just then, a RAB bomb disposal team went to the scene that was cordoned off. The force was being strengthened continuously.

Around half an hour later, reliable sources told The Daily Star that police have tried to communicate with the gunmen but failed. Police have yet to know if the hostage-takers have any demand.

Around midnight, a top DMP official was heard making queries while talking to a colleague whether police had gas grenade, sound grenade or hand mine.

Around 2:30am today, it was learnt that Rab was preparing to start a commando operation.

'THEY WOULD KILL US'

Mohammad Suhrawardy, whose residence is just by the restaurant and who was somewhere else, said his wife called him around 10:30pm and said all of a sudden she heard gunshots at the restaurant that sank into the darkness immediately afterwards.

“Then the restaurant gate was closed and there was a hue and cry,” he told The Daily Star, quoting his wife as saying.

He said his wife asked him not to come home.

A top official of an engineering firm, his wife and two children remained trapped in the restaurant, his uncle told The Daily Star.

The hostage called his uncle -- first at 10:35pm and the second time at 10:40pm.

“They've held us hostage. If possible, tell police not to fire. They would kill us then,” his uncle quoted him as saying, and said he later found his nephew's mobile phone switched off.

Seven to eight students of a private university were also trapped inside the restaurant.

"They were pointing guns at us," the father of one student quoted his daughter as saying.

At least 20 family members of some hostages were seen waiting anxiously at a point near the spot.

One of them said his son came from Canada just yesterday and went to the restaurant to buy food.

"I couldn't communicate with him," said the father.

A huge number of police, Rab and BGB personnel as well as other special forces rushed to the spot by around 9:00pm. They took positions all around the restaurant and also on the roofs of different buildings.

REACTIONS

The attack comes amid a series of secret killings carried out by suspected militants across the country.

Over the last two years or so, suspected militants have attacked and killed university professors, writers, publishers, secular bloggers, gay rights activists, foreigners, policemen and members of religious minorities, including Shia and Sufi Muslims, Christians and Hindus.

The Islamic State reportedly claimed responsibility for a number of such killings.

After the Gulshan attack, foreign diplomatic sources said they are worried because their citizens and diplomats living in Dhaka never guessed any such high voltage situation in Bangladesh.

In Washington, State Department spokesman John Kirby told reporters: "We are aware of reports of what appears to a hostage situation in the Gulshan neighbourhood of Dhaka."

He said the department is aware that local security forces are on the scene, responding, and the US Embassy is in constant touch with Bangladeshi authorities concerning what is a "very fluid, very live situation."

Kirby said the embassy has accounted for 100 percent of American citizens that are under the authority of the diplomatic chief of mission in Dhaka. He said he had no more details, reports ABC news.

He said it was too early to say who were involved in the assault and their motivation

In an abrupt decision, the US, UK and Australian governments issued travel alert for their citizens staying in Dhaka asking them to maintain high degree of caution in Bangladesh due to the high threat.

The British government said, “There are reports of a firearms incident in the Gulshan 2 area of Dhaka. The incident may be ongoing. If you are in the area you should remain vigilant and follow the advice of the local security authorities.”

The US Embassy in its Facebook and twitter message said at 11:00pm said, “There are reports of a shooting and hostage situation in Gulshan 2, Dhaka. Please shelter in place and monitor the news.”

The Australian government told its citizens “If you are in the area, remain vigilant and follow the advice of local authorities. The level of advice has not changed. You should exercise a high degree of caution in Bangladesh.”

“We advise you to exercise a high degree of caution in Bangladesh due to the high threat of terrorist attack and the uncertain political situation. Pay close attention to your personal security at all times. Monitor the media and other sources about possible security risks.

There is reliable information to suggest that militants may be planning to target Australian and Western interests in Bangladesh,” the Australian travel advice said.