Detectives raided a Jamayetul Mujahideen Bangladesh (JMB) hideout in the capital around midnight following a tip-off, triggering a shoot out with police.
"Two militants were wounded as police fired back after the militants hurled a grenade and started shooting indiscriminately. They were declared dead after they were brought to Dhaka Medical College Hospital," a police statement said.
One of the commanders named as Kamal, alias Hiron, was a suspect in the attack on Dhaka's packed main Shiite shrine in October that left two dead and dozens injured.
Three JMB militants were also arrested during the overnight raid, police said.
Also Read
Police have stepped up a crackdown on local Islamist militants after the Muslim-majority country was left reeling from an upsurge in deadly violence last year blamed on religious extremists.
The government rejects the Islamic State's claims of responsibility for many of the attacks, including the shooting murders of two foreigners.
Prime Minister Sheikh Hasina's secular government insists the jihadists have no presence in the country. It instead accuses the JMB and other local militant groups as well as the Islamist-allied political opposition of trying to destabilise the country.
In November, police shot and killed another JMB commander, called "Albany", accused of being the main suspect in the Shiite shrine blast.
Experts fear the JMB is attempting to regroup, years after its top leaders were executed over a 2005 nationwide bombing campaign by the group in a failed effort to introduce Sharia law.