The July 1 terrorist attack in Dhaka hit unnervingly close to home. The Bangladeshi side of my family lost a relative -- Faraaz Hossain, a 20-year-old student at Emory University in the U.S. who was home for the holidays.

I had been at the site of the massacre, the Holey Artisan Bakery, in Dhaka's upscale Gulshan neighborhood, twice during my last visit to the country. Personal grief aside, this is the most visible manifestation yet of the threat that a new generation of self-styled jihadis poses to a country that prides itself on its moderate, secular, pluralistic society.

After the attack, Prime Minister Sheikh Hasina vowed to bring all terrorists to justice and condemned those who killed in the name of Islam. Is this finally a wake-up call for a government that has too often underplayed the radical Islamist threat?

The attackers, eyewitnesses said, singled out foreigners, declaring they were there to kill non-Muslims. The majority of the 22 victims hacked to death or shot were foreigners. The venue in the capital's diplomatic zone, the targeting of mainly foreign victims and the brutal manner in which they were killed were all deliberate choices. The intention was clearly to gain maximum international publicity and to strike fear in the hearts of Bangladeshi citizens.

SHOCK VALUE The Islamic State group was quick to claim credit, posting pictures of the bodies on social media to ensure maximum shock and anguish. Skeptical experts and officials, however, have pointed to the likely involvement of local sympathizers or affiliates of rival al-Qaida in the Indian subcontinent, or AQIS. Whatever the investigations reveal, the government's primary challenge will be to tackle local Islamic State supporters and AQIS, as the constituencies of both organizations are clearly growing. Without robust official action, these rival groups could continue to up the ante, competing for space and public attention, with dire implications for Bangladesh and its neighborhood.

One such group, Ansarul Islam, an AQIS ally, has killed scores of secular and atheist bloggers and publishers in the capital since 2013. Earlier this year, the group murdered a leading Bangladeshi gay rights activist and U.S. Embassy employee, Xulhaz Mannan, and a friend in Dhaka. An Islamic State sympathizer, the Jamaat-ul Mujahedeen Bangladesh, active since the early 2000s, is responsible for killing Hindu priests, Buddhist monks and Shias, mostly outside Dhaka. Since 2013, such attacks have claimed more than 70 lives.

In June, responding to domestic criticism and international concern, the Awami League-led government initiated a weeklong crackdown, reportedly arresting some 14,000 people. But civil society groups have alleged massive police extortion and abuse, and the opposition Bangladesh Nationalist Party and Jamaat-i-Islami claim their activists have been the primary targets. That Hasina's government has repeatedly blamed both parties for the killings lends credence to their claims.

POISONOUS POLITICS The government's preoccupation with suppressing political opposition and dissent has certainly helped to create an environment for groups like Ansarul Islam and JMB to grow. Publicly criticizing atheist and secular bloggers for offending religious sentiments, Hasina and her senior officials have said the government cannot be held responsible for the consequences of such writings. Such mixed messages, and abdications of government responsibility, are also unlikely to foster public confidence in the state's ability to confront the growing jihadi challenge.

The Holey Artisan Bakery attack shows how little the weeklong crackdown managed to achieve. If it is to succeed in stemming the jihadi rot, the government must adopt a counterterrorism approach based on accountable and impartial law enforcement driven by credible investigations, intelligence-gathering and case-building, and anchored in the rule of law. If Hasina intends to follow through on pledges made after the attack to bring terrorists to justice, much-needed institutional reforms should start now. Heavy-handed, indiscriminate and politicized police and paramilitary operations are not only likely to fail but will also breed more resentment against the state.

The July 1 bloodbath marks a major escalation from those that had previously targeted individuals. It should prompt the government into a more serious effort to dismantle local groups linked to the most dangerous transnational jihadi outfits, Islamic State and AQIS. It should not, as in the past, turn the threat into a partisan issue.

Even as she condemned the attack, the prime minister pointed a finger at those who "have resorted to terrorism after failing to win the hearts of people democratically," an implicit reference to the BNP. As politicized cases against BNP chief Khaleda Zia and other top opposition members continue to pile up, and as the government increasingly closes off legitimate avenues of dissent, this zero-sum rivalry with its mainstream opponents has so far yielded a single winner: violent extremists. The Holey Artisan Bakery attack must not become their victory lap. Bangladesh cannot afford to lose more young liberal minds like Faraaz.

Shehryar Fazli is the International Crisis Group's senior analyst and regional editor for South Asia.