The militants were cornered in a hideout on the outskirts of the capital and, having refused to surrender, were killed in the ensuing gunbattle, 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.
The success notched up by the security forces came ahead of a visit on Monday by U.S. Secretary of State John Kerry, who is expected to discuss security in the wake of a series of killings of liberals and religious minorities in the mostly Muslim country.
Islamic State claimed responsibility for the assault on the cafe in a posh neighbourhood of the capital, during which militants singled out non-Muslims and foreigners, killing Italians, Japanese, an American and an Indian.
The government has steadfastly denied the presence in the country of any transnational militant organisation, like al Qaeda or Islamic State.
But police believe that Jamaat-ul-Mujahideen Bangladesh, which has pledged allegiance to Islamic State, was involved in organising 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.
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.
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.
The raid followed a tip off 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.
Police have also been holding in detention two men who had been among the survivors of the attack on the restaurant.
Hasnat Karim, holds dual British and Bangladeshi citizenship, and Tahmid Hasib Khan, a student of Toronto University, 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.
Earlier this month, security forces arrested four women suspected of being members of Jamaat-ul-Mujahideen Bangladesh.
(This story has not been edited by NDTV staff and is auto-generated from a syndicated feed.)
Follow NDTV for latest election news and live coverage of assembly elections 2019 in Maharashtra and Haryana.
Subscribe to our YouTube channel, like us on Facebook or follow us on Twitter and Instagram for latest news and live news updates.