DHAKA (Reuters) - Bangladesh security forces killed three Islamist militants on Saturday, including a Bangladesh-born Canadian citizen accused of masterminding an attack on a cafe in Dhaka last month that killed 22 people, mostly foreigners, police said.

The militants were cornered in a hideout on the outskirts of the capital and, having refused to surrender, were killed in the ensuing gun battle, Monirul Islam, the head of the Dhaka police counterterrorism unit, told Reuters.

He initially said four militants had been killed but later revised the number to three.

U.S. Secretary of State John Kerry is due to visit on Monday to discuss security after a series of killings targeting liberals and religious minorities in the mostly Muslim country.

Islamic State claimed responsibility for the assault on the cafe in a posh neighborhood where militants singled out non-Muslims and foreigners, killing Italians, Japanese, an American and an Indian.

The government has consistently denied the presence in the country of any transnational militant organization such as al Qaeda or Islamic State.

But police believe that Jamaat-ul-Mujahideen Bangladesh, which has pledged allegiance to Islamic State, was involved in organizing the cafe attack.

The scale of that attack and the targeting of foreigners has cast a shadow over foreign investment in the poor South Asian economy, whose $28 billion garments export industry is the world’s second largest.

“This operation definitely will uphold confidence and the image of Bangladesh,” said Bangladesh’s prime minister, Sheikh Hasina.

Slideshow ( 8 images )

She told a news conference: “With this killing one curse has been removed from our shoulders.”

MASTERMIND’S DEATH

The suspected mastermind killed in Saturday’s raid was identified as Tamim Ahmed Chowdhury, a 30-year-old Canadian citizen born in Bangladesh. Analysts say Islamic State in April identified Chowdhury as its national commander.

“According to our evidence we are now sure that Tamim was among the three killed,” Home Minister Asaduzzaman Khan told reporters. “So the chapter of Tamim has ended here.”

Khan said Chowdhury was one of the main suppliers of funds and arms for several recent attacks. He had returned to Bangladesh in October 2013 via Abu Dhabi, A.K.M. Shahidul Hoque, the inspector general of police, said.

Global Affairs Canada, the country’s foreign department, said in a statement it is aware of reports of Chowdhury’s death.

“Canadian officials are in contact with Bangladeshi authorities to gather additional information,” a spokeswoman said. “No further details can be provided at this time.”

The raid followed a tipoff from the landlord of the house where the militants were staying, Hoque told reporters. The landlord said the militants had described themselves as businessmen in the medical trade.

Slideshow ( 8 images )

Police spokesman Masudur Rahman said the fingerprints of two associates of Tamim who were also killed on Saturday have been sent to the election commission to confirm their identity.

“Police collected evidence from the house though they (the associates) destroyed a laptop and some other documents,” he said.

They rented the house earlier this month and police recovered several grenades, arms and bullets.

Last month police offered a 2 million taka ($26,000) reward for information enabling them to detain Tamim.

Police have also detained two men who had been among the survivors of the July 1 restaurant attack.

Hasnat Karim, who holds dual British and Bangladeshi citizenship, and Tahmid Hasib Khan, a student of Toronto University and a Canadian permanent resident, had been dining separately in the restaurant.

A lawyer for Karim, a 47-year-old engineer, has said his client is innocent. Relatives of Khan, 22, say he is innocent too.

Global Affairs Canada said officials are in contact with their Bangladeshi counterparts about the matter, but the assistance they can offer is limited as Khan is not a citizen.

Earlier this month, security forces arrested four women suspected of being members of Jamaat-ul-Mujahideen Bangladesh.