KABUL, AFGHANISTAN – With more than $379 million spent, scores killed, and months of nation-building lost, the Afghan elections have proved a debacle in the eyes of seemingly everyone from fruit vendors in Kabul to world leaders.

An exercise that was intended to build popular legitimacy for the central government in Kabul instead ended with an election marred by fraud that has returned President Hamid Karzai to power, but undermined both his domestic and international standing. His main presidential challenger, Abdullah Abdullah, described the outcome as "illegal" on Wednesday, and said he would no longer contest the result. "I leave it to the people of Afghanistan to judge,'' he told reporters.

It's hard to argue that Afghanistan is better off thanks to the recent electoral process– or that the election will help President Karzai's government, hamstrung by internal corruption and a raging Taliban insurgency, extend its influence across the country and improve the lives of the Afghan people writ large. President Barack Obama is currently considering a "surge" of 40,000 additional troops to Afghanistan as part of an overall strategy that rests on the ability of Karzai and his foreign allies to improve the economy and security.

That task has been complicated by the UN's announcement Thursday that it is pulling 600 of its 1,100 international staff out of Afghanistan in the wake of an attack that killed five UN employees in Kabul last week. Aid groups have found it increasingly difficult and unsafe to operate and have been reducing staff and pulling back those that remain to major population centers like the capital.

But even if elections have left a sour taste, and Karzai has taken political hits from the election, a recent survey found that Afghans don’t disdain the government in general as much as is often portrayed.

The percentage of Afghans giving the government a positive assessment rose to 71 percent, against 67 percent in 2008 and 80 percent in 2007, according to a new Asia Foundation survey of 6,406 Afghans across all 34 provinces conducted in June and July. Confidence in government ministers stood at 53 percent, whereas those expressing some sympathy for insurgents reached 56 percent.

Corruption came in at No. 2, just behind security, as the biggest failing of the government. But when Afghans ranked their country's problems, corruption came in fourth – well below insecurity, unemployment, and the poor economy.

Given the primacy of more basic concerns, the new government’s legitimacy will come more from its ability to improve conditions than from the voting process, argues John Dempsey, a legal expert in Kabul with the United States Institute of Peace.

Karzai vowed to prioritize fighting corruption and building stability, peace, and national unity in a postelection speech on Monday.

But his rival Abdullah Abdullah pooh-poohed Karzai’s prospects in his own press conference Wednesday. “A government, which in its formation is based on an illegal decision by a body, to hope that the second government would deliver in dealing with the corruption, issues of governance, [improving] security in this country, it sounds like an exaggeration,” he said.

And the recent withdrawal of UN workers underscores the tough task ahead for Karzai. On Monday, the UN said it was suspending all development work along the Afghan-Pakistan border because of the deteriorating security situation there. Kai Eide, the head of the UN mission in Afghanistan, described the drawdown as temporary in a press conference on Thursday: "We are not talking about pulling out, and we are not talking about evacuation. We are simply doing what we have to do, following the tragic event of last week, to look after our workers in a difficult moment while ensuring that our operations in Afghanistan can continue."