DHAKA (Reuters) - Bangladesh police on Tuesday shot dead a suspected militant commander and a close aide of the mastermind of the cafe attack last year that killed 22 people, mostly foreigners, a police official said.

Police said Abu Musa, 32, was a close associate of Jahangir Alam, one of the masterminds of the July attack who was arrested last month, and wanted for killings of religious minorities and a Japanese citizen in the northern region. Alam not been formally charged.

Musa was killed in a shootout when police raided a town in Bogra district, about 200 km northwest of the capital, Dhaka, local police chief Nur Alam Siddiqui said.

“We had to fire back when a group militants opened fire on a police patrol,” he said, adding police also recovered firearms and other weapons.

Musa was a commander of a faction of the Jamaat-ul-Mujahideen Bangladesh (JMB) militant group, known as New JMB, which has pledged allegiance to Islamic State, and which police believe was involved in organizing the cafe attack.

Islamic State claimed responsibility for the July 1 assault, when gunmen charged into the cafe in the diplomatic quarter. Nine Italians, seven Japanese, an American and an Indian were among the dead.

The five gunmen who attacked the cafe were all killed.

Police have killed about 50 suspected militants in shootouts since the attack, including the man they say was its main planner, Bangladesh-born Canadian citizen Tamim Ahmed Chowdhury.

Al Qaeda and Islamic State have made competing claims for a series of killings of liberals and members of religious minorities in the country over the past year.

The government dismissed the claims and instead blamed domestic militant groups, but security experts say the scale and sophistication of the cafe assault suggested links to a trans-national network.