DHAKA, Bangladesh — Bangladeshi Army troops moved in on Saturday to end an 11-hour standoff at a restaurant in Dhaka, the capital, after gunmen stormed into the building, detonated explosives and took at least 20 people hostage on Friday night.

Gunfire and explosions could be heard as the soldiers, backed by armored vehicles, swept in to the restaurant in the city’s diplomatic district at 7:40 a.m. on Saturday. At least a dozen people were rescued, including several foreigners, the police said.

Two police officers were killed in the initial standoff with the attackers, and 30 people were wounded, mostly from shrapnel, officials said. A police inspector said that at least five militants had been killed in the rescue operation.

Details about other fatalities or injuries from the attack or the rescue operation were not immediately available.