Security personnel keep watch at the restaurant in the Gulshan area of Dhaka where armed men took hostages. Mohammad Ponir Hossain/Reuters
Since gaining independence in 1971, Bangladesh - the world's third-largest Muslim majority country - has made remarkable social and economic progress. Once branded a basket case, the rate of the country's social progress is now faster than its neighbour India.
It's been hailed as a model for reducing hunger and recently was identified as among top destinations for investment in Asia. Indeed, Japanese companies rate Bangladesh as their number one investment destination.
Despite this progress, Bangladesh has been experiencing a wave of violence by Islamic extremists since 2013.
On the night of July 1 2016, five young local men armed with blades, guns and bombs stormed a restaurant in the neighbourhood of Gulshan in the capital Dhaka, and took foreigners who were dining there hostage. The siege resulted in the death of 22 people in all, including nine Italians, seven Japanese, a US citizen and an Indian. Following hours of a stand-off, a military raid saw all but one of the attackers killed.
The Gulshan attack was the latest in an irregular killing campaign carried out by alleged violent extremist groups. They are said to be responsible for 40 killings, including bloggers who were alleged to be atheists, a US embassy employee who was a gay rights activist, and Sufi Muslims, who denounced a rigid interpretation of scripture.
But until the terrorist attack in Gulshan, people had little idea about the background of extremists in the country. Once details emerged from official sources about who the Gulshan attackers were, the whole country was in shock.
Unlike the popular image and media portrayal of Muslim terrorists, who are assumed to have beards and poor economic backgrounds, wear traditional Islamic attire and are supposed to have been educated in Islamic schools (madrassas), four of the men came from affluent, privileged families, and had modern English-language schooling.
Following the Gulshan attack, officials have publicly acknowledged that, for the past couple of years, a growing number of young Bangladeshi men have been noted missing, and a small number of them may have joined militant outfits. Some of these missing youths returned after a list was made public and some were found to have left home due to differences with their parents.
The list showed that many of the missing young men had been trained in public universities, private universities, English schools, alongside madrassas. This poses several problems for policymakers and Bangladesh's development partners.
The country has many programs aimed at modernising madrassa education and training imams, who lead prayers in mosques and offer sermons during Friday prayers. These signature projects are funded by international donor agencies to counter radicalisation. They - explicitly and subtly - make the point that certain people who are "different" in terms of their lifestyle choices, and are educated in a religious system, are vulnerable to extreme and violent ideology.
A similar bias appears in a plethora of writings that identify violent extremism in Bangladesh as a threat to secularism. These, too, ignore the fact that the country already hosts a deeply conservative society; prime minister Sheikh Hasina has repeatedly clarified that secularism is not devoid of Islam or Islamic secularism.
In reality, it is Islam - a religion close to the hearts of millions of Bangladeshi Muslims - that is under assault from violent extremists.
Bangladesh's fight against violent extremism, then, needs to be seen as a contest between a pluralist Islam and a rigid construction of the religion by extremists. But why are Bangladeshi youths - however few they are - joining the ranks of violent extremists?
Three phenomena may be responsible: Bangladesh's demographic youth bulge; the country's changing social landscape through rapid urbanisation and digitisation; and its democratic deficit.
Demographic youth bulge
Bangladesh is currently going through a "youth bulge" as a result of population growth slowing down significantly in the past three decades.
According to a latest report of International Labour Organisation (ILO) currently 29.6 million Bangladeshis are aged between 15 and 24, and 40% of them are not in education, employment or training. That means 11.8 million Bangladeshi youths are inactive.
Even a large proportion of those who complete university education might end up unemployed; a 2014 report found that nearly five out of every ten graduates in Bangladesh was unemployed. This social dynamic is identical to that facing Middle Eastern countries before the Arab Spring.
It's very possible that some of these young people become frustrated and harbour anger towards society, making them are ripe for recruitment by militant outfits.
Urbanisation and digitisation
Bangladesh's changing urban landscape and rapid digitisation have also played a part.
Once known for its vast farmland and underdevelopment, the country is now going through faster urbanisation than the rest of South Asia. Farms, fields, parks are being replaced by apartments, bridges, factories and shopping malls, and affordable housing is becoming a problem.
While the change in the urban landscape has resulted in decreasing space for playing fields and socialising, Bangladesh has also been going through rapid digitisation, thanks to the government's Digital Bangladesh policy. This has not only increased internet users, but also brought change in social behaviour.
According to one estimate, the number of internet users in Bangladesh shot up from 93,261 in 2000 to 21,439,070 in 2016. That more young people are connecting online is unlikely to have gone unnoticed by recruiters for militant groups.
The spark in this tinder is Bangladesh's rather serious democratic deficit. Commentators and rights organisations have voiced repeated concerns about Bangladesh's lack of democracy, worrying trends in human rights, and lack of space for opposition politics.
The 2014 election was boycotted by major opposition party (Bangladesh Nationalist Party) and its allies ending up in a one-sided result that installed the current government led by the Awami League.
The environment is unfavourable for dissents, and against this backdrop an easy option left for young people is to join the student wing of the ruling party. Of those not willing to do so, a few may have opted for extreme outfits operating covertly.
Countering violent extremism in Bangladesh will require a change in the political climate of the country so that young are exposed to diverse political avenues and have a real chance of getting a job. It will also need a massive online campaign to deter extremist propaganda. Only by addressing the country's social and political problems will Bangladesh have the chance to move in the right direction.