Officials say three suspected Muslim militants have been killed inside a building after security officials cordoned it off and opened fire in Bangladesh's capital.

Head of Rapid Action Battalion agency Benazir Ahmed says the operation took place in Dhaka's Tejgaon area on Friday following information that some of the suspects have been staying in a rented apartment.

Officials say they recovered the bodies and explosives inside the Ruby Villa five-story building near the office of Prime Minister Sheikh Hasina.

Details of the suspects' identities are not clear immediately.

Bangladesh has been battling a rise of Islamic militancy for the last few years. In July 2016, five militants killed 20 hostages including 17 foreigners in a Dhaka restaurant.