Bangladesh's prime minister said the nation was "free of another curse" on Saturday after police stormed a militant hideout, shooting dead the suspected mastermind of a horrific attack on a cafe that killed 22 hostages.
The bodies of three Islamist extremists were retrieved after police staged an hour-long gun battle with militants in Narayanganj, a city 25 kilometres (16 miles) south of Dhaka, officers said.
Prime Minister Sheikh Hasina praised police and intelligence agencies for the operation which killed Tamim Chowdhury, a Bangladeshi-Canadian believed to have planned the attack.
"The main mastermind of the Holey Artisan (attack) has been eliminated," Hasina told reporters at her office, referring to the Gulshan cafe incident.
"The nation has become free of another curse," Hasina said, adding that the "elimination of the extremists" would bolster "people's confidence".
The police raid came two days before US secretary of state John Kerry is set to arrive in Bangladesh, the highest-ranked Western official to visit the South Asian nation since the attack.
Officials said security issues, including Dhaka-Washington DC anti-terror cooperation, will feature during Kerry's talks with his Bangladeshi counterpart on Monday.
Thirty-year-old Chowdhury, who returned from Canada in 2013, had earlier been named by police as the suspected mastermind of the attack on the cafe in Gulshan, an upscale Dhaka neighbourhood.
"The operation went on for an hour. We can see three dead bodies. They did not surrender. They threw four to five grenades at police and fired from AK 22 rifles," Bangladesh national police chief AKM Shahidul Hoque told reporters Saturday.
"Three extremists were killed. Among them, one of the dead persons looked exactly like the photo of Tamim Chowdhury that we have," he said.
The Islamic State group claimed responsibility for the July 1 attack, releasing photos from inside the cafe during the siege and of the five men who carried out the deadly assault and were shot dead at its finale.
But police and the Bangladesh government rejected the IS claim, saying a new faction of homegrown militant group Jamayetul Mujahideen Bangladesh (JMB) led by Chowdhury was behind the attack in which 20 hostages, including 18 foreigners, were killed along with two policemen.
Police blame the JMB for the deaths of more than 80 foreigners and members of religious minorities over the last three years.
"Tamim Chowdhury's chapter is closed here," Bangladesh home minister Asaduzzaman Khan told reporters after visiting the site of the raid Saturday.
He said other extremists were "very few" in number and face imminent arrest.
A series of raids on suspected militant hideouts carried out with the Rapid Action Battalion elite security force have killed at least 24 extremists since the cafe attack.
Police on August 2 announced a two million Taka ($25,000) reward for information leading to the arrest of Chowdhury, who disappeared after the attack.
Police say Chowdhury has led and financed efforts to radicalise young Muslims since returning from Canada three years ago.
His role in fostering extremism was revealed during the interrogation of Rakibul Hasan, 25, who was arrested in a raid on a militant hideout in July in which nine extremists were killed in Dhaka.
A police report into that raid said Chowdhury and others gave Hasan and other militants "money, explosives and weapons" and "trained and advised" them.
Bangladesh has been reeling from a deadly wave of attacks in the last three years, including on foreigners, rights activists and members of the country's religious minorities.
In June more than 11,000 people were arrested in a bid to quash a spate of brutal murders of secular writers, gay rights activists and religious minorities.
Both IS and a branch of Al-Qaeda have claimed responsibility for many of the attacks.
Bangladeshi authorities have rejected the claim, saying international jihadist networks have no presence in the world's third-largest Muslim-majority nation.
Critics say Prime Minister Hasina's administration is in denial about the nature of the threat posed by Islamist extremists and accuse her of trying to exploit the attacks to demonise her domestic opponents.