KABUL  - As he celebrated re-election, US President Barack Obama spoke of his desire to ‘shape a peace’ in his second term, but he faces huge challenges in Afghanistan, where he must end his country’s longest war.

From the very early days of his presidency in 2009 Obama has learned the hard way that plans laid in Washington often crumble in the hard realities of the land known as the ‘Graveyard of Empires’. He came to power in the middle of an economic crisis with the intention of bringing American troops home from Afghanistan but ended up sending a ‘surge’ of 33,000 extra soldiers to try to quell the Taliban.

Now these reinforcements have come home and the 100,000-strong Nato force, nearly 70,000 of whom are American, are preparing to follow suit by the end of 2014.

But the land they will leave behind is not peaceful - the insurgency led by the Taliban is not beaten and a growing number of analysts believe the 350,000 Afghan security forces supposed to take over after 2014 are not capable of preventing a return to civil war. As the 2014 deadline approaches, Obama faces difficult questions over whether to negotiate with the Taliban to try to secure peace and how many US troops to leave in Afghanistan after that date to help the Afghan forces. For Maleeha Lodhi, former Pakistani ambassador to Washington, the next two years will be crucial.

“It is what will happen between now and 2014 which will determine the course of post-2014 Afghanistan and post-war region,” she said at a conference in Islamabad this week.

The best outcome, she said, would be a negotiated settlement following peace talks between the US and the Taliban, but she warned this was a distant prospect. “For now there is no peace strategy, there is no framework, there is no road map to get to this destination. Everybody agrees they want to get there but nobody has charted a clear way forward,” she said. Preliminary contacts between the Taliban and the West began in Qatar but the process is now dead in the water, terminated in March by the insurgents after they failed to nail a deal with Washington on the release of five of their comrades imprisoned in Guantanamo Bay.

Moreover, Washington’s decision in September to blacklist the Haqqani militant network, a key Taliban faction close to Al-Qaeda, as a terrorist organisation will complicate any efforts towards talks with the insurgents, she warned.

Pakistan, where a number of Haqqani leaders are believed to be hiding out and which has historically been close to the Taliban, will have a key role in any possible talks.

“Any efforts towards substantial talks with the Taliban before 2014 would have to be shared with other regional players, including Pakistan,” a senior western diplomat in Kabul said, speaking on condition of anonymity.

The militants also have the option simply to wait until Nato forces leave.

Stephen Biddle, a professor of international affairs at George Washington University, warned “announcements of troops withdrawals... tend to reduce our leverage for bargaining”.

Obama must also decide on what level of military presence to leave once the torch finally passes to the Afghans - Washington has not yet said how many “non-combat” troops will remain in the country after 2014.

For this he needs to reach an understanding with his Afghan allies on two thorny issues: keeping US bases in Afghanistan long-term and the legal status of the US soldiers who will stay to train Afghan forces.

Kabul has warned that there could be problems in agreeing to legal immunity for American soldiers, as Washington demands. Several American analysts have voiced optimism about a future deal on these issues, though Michael O’Hanlon of the Brookings Institution think tank warned talks would be “ugly and slow”. It is a crucial point - in Iraq the failure to secure legal immunity led to Washington pulling out its troops completely.