The bodies and explosives were found inside the building near the office of the prime minister, said anti-crime Rapid Action Battalion (RAB) chief Benazir Ahmed.
"We found three bodies at the end of our operation," Ahmed said.
The operation was carried out in Tejgaon area following information that some of the suspects were staying in a rented apartment.
Residents in the neighbourhood said exchange of gunshots and explosions rocked the scene as the RAB, which draws personnel from both army and police, cordoned off the six- storey apartment complex after midnight last night.
Ahmed said the militants rented the fourth floor of the building pretending as ordinary tenants since the beginning of this month while the security forces found unexploded explosives, including grenades after the raid.
"We began the operation after confirming that the militants are living on the particular floor... we planned so the other residents of the building are unhurt," RAB spokesperson Mufti Mahmud Khan told reporters.
He said the bodies were found as the RAB men broke into the apartment earlier today as no response was received from inside but did not immediately say which terrorist outfit they belonged to.
Neighbours said they hardly saw the residents of the fourth-floor since they rented the house and always found its door and windows closed.
Bangladesh has been battling a rise of Islamic militancy for the last few years as the militants targeted liberals including atheist bloggers, foreigners and minority groups.
In July 2016, five militants stormed a restaurant and killed 20 hostages, including 17 foreigners in Dhaka's Gulshan diplomatic area. An Indian girl was among those killed in Bangladesh's worst terror attack.
Hasina's government says the militants' network has been weakened significantly after a security crackdown and the killings of more than 60 suspects including some top commanders since the restaurant attack.
(This story has not been edited by Business Standard staff and is auto-generated from a syndicated feed.)