Over the last two weeks, the streets of Dhaka, the capital of Bangladesh--a country once touted as a model of moderate, Islamic democracy--looked more like Baghdad or Karachi. Thousands of protesters charged through Dhaka's alleys and tin-roofed slum dwellings. They attacked stores and clashed with riot police and thousands of soldiers, battling with stones and sticks until some demonstrators fled the scene, their faces bleeding and clothes ripped apart. In just three days last week, the violence escalated, leaving more than 100 people injured.

The riots cap years of turmoil and poisonous politics in Bangladesh, breeding the kind of chaos that is fostering Bangladeshi terrorist groups with links to Al Qaeda. Just since October, similar riots have killed more than 30 people in the country. Indeed, instead of developing into the next Turkey, once-secular Bangladesh may be headed toward becoming the next Afghanistan.

Ostensibly, the riots stemmed from a recent announcement by Bangladesh's opposition leader and former prime minister, Sheikh Hasina, that her 14-party opposition alliance, known as the Awami League, would boycott the January 22 elections. Hasina claims that an interim caretaker government responsible for organizing the polls is biased against her party and should implement several electoral reforms to level the playing field before the election. Seeking to show its power, Hasina's group called for supporters to shut down the capital and other parts of the country through protests and strikes. "Resist the vote thieves," Hasina told her supporters, according to several reports.

In response, Bangladesh's other main party, led by another former prime minister, Begum Khaleda Zia, accused the Awami League of paralyzing Bangladesh's already fragile economy and called for the polls to proceed on schedule, without the reforms.

The protests only reveal larger failures within the country. Bangladesh boasts an educated elite, a history of secularism and tolerance, a strong civil society, a vibrant intellectual life--and nascent interest by foreign investors, who see potential in one of the world's most populous Muslim nations. Dhaka hardly looks like Riyadh or pre-September 11 Kabul: Scantily clad Bollywood stars pose on advertising billboards at major intersections. Women, from Khaleda Zia and Hasina on down, play major roles in Bangladeshi government, business, and society.

But the country has not been well served by its politicians. In fact, in recent years, domestic politics has disintegrated into a blood feud between Khaleda Zia and Hasina, who hate each other. Too often, in a nation where unemployed young men are not hard to round up, this rivalry plays out in political violence on the streets, distracting from the process of governing. Time and again, whichever leader is not in power uses her time in opposition not to parry the government but to call her thugs into the streets and to shut down the economy.

With venomous mainstream politicians like Khaleda Zia and Hasina, and with Bangladeshi elections increasingly devalued, some young Bangladeshis appear to be turning to another alternative: Islamists. Once on the fringe of society, Islamist parties and terrorist organizations have gained prominence in recent years. One recent report by South Asia expert Selig Harrison said that the "growing Islamic fundamentalist movement linked to al-Qaeda and Pakistani intelligence agencies is steadily converting the strategically located nation of Bangladesh into a new regional hub for terrorist operations that reach into India and Southeast Asia." Former State Department terrorism coordinator Cofer Black has echoed that assessment, warning that Bangladesh could become a platform for terrorist groups.

The militants already have made headway. Several Islamist parties have sprung up, including many with strong ties to Bangladeshi militant groups, including Harkat ul Jihad al Islami, Jagrata Muslim Janata Bangladesh, and Jama'atul Mujahideen Bangladesh (JMB). In August 2005, the JMB claimed credit for more than 450 synchronized explosions across the country, and its operatives spread leaflets at the sites of the blasts calling for the establishment of Islamic law. One year earlier, a grenade attack on an Awami League rally killed over 20 people, and Islamist groups regularly attack prominent secular intellectuals and members of religious minorities, sometimes mutilating their bodies in the process. Both Hasina and Khaleda Zia have attempted to co-opt the Islamist parties toward moderation, with little success, and the weak Bangladeshi police force has little ability to crack down on terrorists.

Left unchecked, Bangladesh could become another Afghanistan--a base for regional terrorism--and damage America's growing relationship with South Asia. Yet the United States and other major powers are paying little attention to the crisis in Dhaka. Rather than pushing the caretaker government and the two parties toward a compromise that brings everyone to the polls, the U.S. Embassy in Dhaka has proved passive, merely issuing a statement that "our own support and observation missions will depend on [free and fair elections]." Unless the United States brokers a compromise, further political chaos and a meaningless election might overwhelm the fragile secular political system, leading to intervention by the Bangladeshi army or creating the kind of failed state that occurred in pre-September 11 Afghanistan.

To defuse the crisis, the United States could leverage the roughly $800 million that it gives every year to Bangladesh. Washington could also offer duty-free textile imports from Bangladesh as a carrot to induce compromise. In addition, the United States needs to team up with India to tackle potential terrorism emanating from Bangladesh. For too long, the United States has allowed Bangladeshi terrorist groups to disband only to reappear under different names in different countries.

International pressure and careful public shaming has worked in the past with Bangladesh. In 2001, it took a visit from former President Jimmy Carter before the elections and a public appeal urging the Awami League to accept the results of that year's election which was widely considered to be free and fair by international observers. On January 11, the resignation of Bangladesh's caretaker leader, Iajuddin Ahmed, who was not accepted by both political parties, possibly came due to persistent pressure from the international community, including the United States, the United Nations, and the European Union, among others. But the crisis isn't over yet--the country remains in a state of emergency. In the coming days, the United States might even consider sending diplomats from Washington, not just from the Dhaka embassy, to help stabilize the situation and ensure that free, fair, and credible elections are held with the participation of all political parties.

Thankfully, Bangladesh has not yet imploded. The majority of Bangladeshis remain moderate and secular, and the Islamist parties have never gained more than 10 percent of the total vote. But this once-promising country is heading down a steep slope, and an illegitimate election, followed by more violence, will only make matters worse.

Joshua Kurlantzick is a special correspondent for The New Republic. Anirudh Suri is editor of South Asian Perspectives, a monthly publication of the Carnegie Endowment for International Peace.