On Thursday, Afghanistan will hold the second presidential election in the country's history. While every election in Afghanistan is a reason to celebrate, the mood surrounding this vote will not match that of the country's first ballot, held five years ago.

That's because there is a fear that the country is losing its way, that the Taliban are resurgent and that the government in Kabul is unable to stop them. Another successful vote in Afghanistan will be an important step forward in the country's development, but it is only a part of a much larger process — the creation of a safe and stable society, a competent government and a growing economy. All are in short supply.

It has been a rough five years for Afghan President Hamid Karzai. Against high odds, he emerged as the country's leader after the United States drove the Taliban from power in the aftermath of the Sept. 11, 2001, terror attacks. While Mr. Karzai's ascendance was primarily a result of his being a Pashtun, a member of the country's largest ethnic group, he also proved to be a consummate deal maker, and was able to win support from the warlords and tribal leaders who exercise real power in Afghanistan.

His ability to strike deals won him political backing, but it undermined the central government. The autonomy those leaders demanded in return for their support deprived Kabul of badly needed revenues and contributed to an image of a weak and corrupt president whose real domain was restricted to the capital. At the same time, the U.S.' focus on Iraq, and relative neglect of its initial war front, allowed the Taliban to regroup and resume fighting. The result has been a growing insurgency in the south and east. The top U.S. general in Afghanistan recently said the Taliban had gained the upper hand in the country, having expanded beyond their traditional strongholds, and were now threatening previously stable parts of the country.

For some, that picture is too bleak. The Taliban may be coming back and Afghanistan has a long way to go, but attention should be paid to the gains that have been made. Most of the country enjoys peace, the economy is growing, development is under way — albeit more slowly than anyone would like — and the U.S. has shifted its focus away from Iraq to give Afghanistan the attention it has deserved.

While there are frustrations with Mr. Karzai, he remains popular. A recent opinion poll showed two-thirds of Afghans have a favorable opinion of their president; only 16 percent had an unfavorable view. Mr. Karzai is currently expected to win the tally Thursday, although he may not get the 50 percent needed to avoid a runoff. There are more than 40 candidates in the upcoming ballot, but the president's main challenger is Mr. Abdullah Abdullah, a former eye doctor who fought the Soviet invaders and the Taliban, and served for five years as Mr. Karzai's foreign minister. He enjoys support from the largest opposition group, the National Front, a northern group. Success in the election depends on whether he can extend his base. That's possible only if he unites the opposition in a runoff.

At present, polls show Mr. Abdullah taking 20 to 25 percent of the vote. The same polls show Mr. Karzai falling short of the 50 percent threshold. The outcome may rest in large part on how successful the Taliban are in disrupting the vote. Afghans ignored similar threats in 2004, and pictures of voters raising stained thumbs after voting was an inspiration for millions of people around the world.

A more formidable Taliban presence might make those threats more credible. The insurgents have already begun to pick up the pace of attacks. It is estimated that violence could prevent 10 percent of the polling stations from opening. Equally troubling, it could promote fraud if the prospect of attacks deters observers from monitoring the balloting.

Elections are always going to be difficult in a country where only about a third of the population are literate. Moreover, a lack of infrastructure means that ballot boxes have to be delivered by donkeys. Religious rules allow men to vote for their wives. And unlike in the 2004 election, security will be provided by Afghan security forces, rather than the international coalition. We hope they can provide safety as well as scrupulous respect for the democratic process.

To their credit, the vast majority of the Afghan people do not seem intimidated. About 75 percent say they will vote in the election, and nearly 80 percent believe the vote will be secure.

Their courage and resilience demand more from their leaders. The winner of this election must rally the entire country to his side, to break the grip of the warlords and build the strength of the central government. That will help provide a bulwark against the Taliban and marshal resources that the country desperately needs to move forward. Building a safe and secure Afghanistan will be a long and painful process, but it is possible — if the country's leaders put the national interests ahead of their own.