Two wars, two surges of U.S. forces — and two vastly different outcomes. Why the difference between Iraq and Afghanistan?

The troop surge in Iraq, which began in 2007, succeeded for a simple reason: The various players (Sunnis, Shiites and Americans) had become desperate. And this collective desperation, even more so than troop levels and strategies, influenced the decisions and actions that ultimately turned the conflict around.

The war in Afghanistan will not be decided solely by troop levels, either. For all the debate it elicited, President Obama’s announcement Wednesday that he will withdraw the 33,000 American surge forces there by September 2012 — including 10,000 by the end of this year — will not determine the outcome of the conflict. Neither will any one military doctrine or battlefield general. After more than five years as a civilian adviser to U.S. forces in Iraq and Afghanistan, it is clear to me that there can be no single blueprint for our military actions abroad.

But it is also clear that the desperation that enabled the success of the surge in Iraq will not materialize in Afghanistan, and that is why a decisive shift in the conflict remains elusive and unlikely. The surge forces have hardly been wasted, but the absence of collective desperation means we must look beyond troop strength to have an impact in Afghanistan — while we still have a strong military, diplomatic and aid presence there.

In 2006 and 2007, before and during the surge in Iraq, Baghdad was a killing coliseum. Shiite militias and sectarian government forces systematically and deliberately eliminated Sunni communities. Civil war raged in the streets, and Iraqi government officials and citizens were routinely targeted and assassinated. Americans built concrete walls throughout the city to protect its residents from the insurgency, but also to make the primary method of intimidation — the dumping of dead bodies in public places, such as markets or on streets in front of homes — more difficult. The sight and stench of death filled the city. Casualties and suicides of U.S. troops mounted; memorial services for our fallen were unending. I was there as a political adviser to the U.S. military division responsible for Baghdad, and for those of us who lived through them, those were truly the darkest of days.

At this epicenter of war, various factors converged to tip the direction of the conflict. First, even before the first surge troops arrived, the mere expectation of their presence weighed heavily on the insurgents. The loud debate in Washington and President George W. Bush’s Hail Mary decision to send additional forces — notably, without a timeline — made the perception of force as important, if not more so, than its application.

Second, as the violence escalated, we placed new emphasis on analyzing and learning about those we were fighting, assessing their motivations and objectives. We mapped the fissures of numerous insurgent groups and exploited them through diplomatic pressure and relentless surgical strikes by U.S. Special Forces.

But most of all, it was the Iraqi people who finally changed the course of the conflict. They were facing violence from all sides: The Shiite-led government used elements in the security forces to fuel sectarian war, and the ruthless killings carried out by these death squads were compounded by al-Qaeda-linked foreign fighters who treated Sunnis with brutality. This compelled ordinary Iraqis to unite in defense of what remained of their communities, in a movement that became known as the Sunni Awakening. American forces and large numbers of Sunnis came together, pooled their resources and transformed the political currents of the conflict.

The dynamics in Afghanistan are starkly different. Unlike in Iraq, this war is rural and dispersed. In Kabul and other major cities across the country, the images and daily experience of war are not as vivid as they were in the streets of Baghdad. Historically, this makes sense: Afghan rulers have traditionally concentrated on urban centers, exerting loose governance, at best, over rural areas. As a result, despite the shrinking of safe space around some cities and sporadic attacks on town centers, Afghanistan’s political and economic elites do not have the same sense of urgency that their Iraqi counterparts experienced in 2007.

This different urban-rural dynamic has also affected our understanding of the insurgency. In Iraq, most insurgent cells were concentrated in Baghdad and other cities, making it easier to focus our intelligence efforts. Ten years on in Afghanistan, however, we still don’t have a clear picture of our enemy. When we use the catch-all term “Taliban” to describe the diverse insurgents, we distort our picture of what various groups and individuals are fighting for, the scope of their control and how we might make peace with reconcilable groups. Instead, the Taliban mythology grows. Its fighters have become fleeting ghosts traveling from village to village; here one day, in Pakistan the next, moving from south to north and spreading throughout the country.

In reality, there are relatively few ardent followers of Mohammad Omar and the Taliban that ruled Afghanistan from 1996 through 2001. Many current fighters are simply rural Afghans who have taken up arms out of a sense of honor or nationalism, or because of economic incentives, or because they have relatives who have been killed or injured. The more we understand this, the more we will realize that many of those we call the enemy do not have the will or the capacity to carry out transnational attacks against the United States or our allies. Regrettably, the perception of force is perhaps the Taliban’s most powerful weapon today.

There will be no Afghan Awakening — at least not while we are there. Though the country may appear in dire straits to Western eyes, it has not reached despair. Many Afghans have experienced far worse: all-out civil war, most recently after the withdrawal of Soviet troops in 1989. After an initial period of peace, the Soviet Union collapsed, and with it the aid that sustained Afghanistan. The Afghan military quickly fractured and then disintegrated. By 1992, the country was in the throes of war, with Kabul shelled to pieces.

Still, even though Afghan elites have been largely separated from the day-to-day fighting, the political stakes in Kabul are rising. For close to a decade, President Hamid Karzai and his inner circle have operated under the assumption that we need them more than they need us. In 2010, Afghanistan received more foreign assistance per capita than any other developing country. But this has started to change. The killing of Osama bin Laden, competing demands for attention and resources in the Arab world, domestic economic priorities, and growing questions about America’s partnership with Afghanistan are converging as the international community reassesses its role.

Diminishing foreign assistance will only heighten the uncertainty leading up to the 2014 Afghan presidential elections, in which Karzai is currently constitutionally barred from running. The transition of power and our long-term support to the next Afghan government will be more important than our own transition out of the country.

Even with this past week’s announced troop reduction, there will still be more than 65,000 U.S. soldiers in Afghanistan in the fall of 2012. Many will be focused on mentoring, training and equipping Afghan forces to eventually take over responsibility for their country’s security. Yet here, too, we must better understand who we are empowering and legitimizing. Political parties, tribes and ethnic groups are increasingly fighting over a smaller pool of resources, and their previous experience with a withdrawing foreign power will certainly loom large. Ensuring that Afghanistan has a sustainable and manageable force — one ethnically and politically balanced in composition and location — will become critical in the months and years ahead.

There is some desperation in Afghanistan — and it may be heightened by increasing political uncertainty and diminishing resources — but it isn’t concentrated in any one place or any one group. The United States, for its part, is increasingly impatient and eager to move on from this war; the sense that this is a necessary fight seems to be gone. Ultimately, the only force that can change Afghanistan will be the collective desire of Afghans for an end to war.

Matt Sherman, a former State Department official, recently completed a two-year tour embedded with U.S. forces in Afghanistan. He served as a political adviser to the U.S. military and the Iraqi government in Baghdad from 2004 to 2007.

Read more from Outlook, friend us on Facebook, and follow us on Twitter.