At least nine terrorists shouting "Allahu Akbar" barged into the Holey Artisan Bakery, frequented by diplomats and expatriates, and opened indiscriminate fire at around 9:20 PM (local time).
Several foreigners, including Italians and Japanese, are feared to have been taken hostage along with locals inside the restaurant, said police.
"We are trying to negotiate with the gunmen holed up inside the restaurant," Rapid Action Battalion (RAB) chief Benazir Ahmed told newsmen. "Our first priority is to save the lives of the people trapped inside."
At least 30 people and policemen, including an Additional Commisioner of Dhaka Metropolitan Police, were injured in the firefight.
More From This Section
The attackers hurled bombs from inside the restaurant, and were firing intermittently. Gunshots and explosions were heard from time to time near the restaurant.
MEA sources in New Delhi said they were monitoring the situation in Dhaka and trying to ascertain the details.
Bangladesh Prime Minister Sheikh Hasina was in touch with security agencies over the incident.
Local media reports said the number of gunmen could be as high as 20 but there was no official word on it.
A kitchen staff of the restaurant, who managed to escape, said several armed men entered the restaurant around 8:45 PM and took the chief chef hostage, according to media reports.
"They set off several crude bombs triggering panic," he added.
It was not clear who the attackers were, but reports said that authorities suspect Islamists to be behind the attack.
The Muslim-majority Bangladesh has been fighting a wave of deadly attacks on religious minorities and secular bloggers by suspected Islamist militants.
On June 7, a 65-year-old Hindu priest was killed by three bike-borne assailants in western Bangladesh.
The ISIS and al-Qaeda in Indian Sub-Continent have claimed responsibility for most of the attacks even though the government has denied their presence in the country.
Last month, police launched a nationwide anti-militancy crackdown to halt these attacks.