The pair were challenged at a rural police checkpoint and killed in an exchange of gunfire, said Munshiganj police chief Zaidul Alam.
Both men were in their early 30s and alleged to be members of Jamayetul Mujahideen Bangladesh (JMB). Police have not disclosed their full names.
The JMB was blamed for the 2016 attack on a cafe in an affluent Dhaka neighbourhood, during which 18 foreigners and four other hostages were killed.
Alam said one of the two men was the "main mastermind" of the killing of publisher and Communist Party official Shahzahan Bachchu near Munshiganj in June.
Top Bangladeshi militant dies in police custody
The other militant was "a JMB bomb-maker" who had taken part in the killing, Alam told AFP.
The killing of Bachchu, 60, was the first militant attack on a prominent secular figure in two years.
Bachchu's death led to fears of a new wave of militant attacks in the country.
Another JMB regional commander, Abdur Rahman, was killed in a gun battle in the central town of Sirajdikhan in June. He had also been accused of involvement in Bachchu's murder.
Security forces have shot dead more than 80 alleged militants over the past two years. Hundreds more have been arrested and scores sentenced to death.
The JMB, founded by Bangladeshi militants who took part in the Afghan civil war in the 1990s, regrouped after the execution of its top leaders in 2007.
COMMENTS
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ