NEW DELHI — Police in Bangladesh killed three suspected militants Saturday, including an alleged mastermind of a major attack on a cafe last month that left 20 people dead.

Police sharpshooters raided a two-story house in Narayanganj district near the capital, Dhaka, after receiving a tip that Tamim Chowdhury, a Bangladeshi-born Canadian, and others were hiding there, top counterterrorism official Monirul Islam said.

Police say Chowdhury is one of two masterminds of the attack on a popular restaurant in Dhaka on July 1 that that killed 20 people, including 17 foreigners.

The militants belonged to the banned group Jumatul Mujahedeen Bangladesh, or JMB, Bangladesh’s police chief A.K.M. Shahidul Hoque told reporters.

Chowdhury is also suspected to be behind a July 7 attack on an Eid gathering outside Dhaka marking the end of the Muslim holy month of Ramadan, he said. Four people died in that attack, including two police officers.

Police said they found guns, ammunition and meat cleavers in the apartment where the men were holed up. The men also set off explosions to destroy their computers and other evidence, said Sanwar Hossain, a senior police officer.

“We heard explosions inside the apartment and we understood that they were destroying evidence,” Hossain said. “When we felt that they would not surrender, we made our final push and killed them.”

When police forced their way into the apartment, they found two bodies near the main door, and Chowdhury’s body was found in another room, Hossain said.

Bangladeshi police have been conducting raids across the country to hunt those behind the attacks.

After storming the building Saturday, a SWAT team made the final push and fatally shot the suspects after they failed to surrender. Haque said the team asked them to give themselves up but that they kept on firing.

The Islamic State group claimed responsibility for the restaurant attack, but authorities have denied the claim, saying it was the act of the JMB and that the IS has no presence in the Muslim-majority country.