It was Ali Zeidan’s first official visit to Washington and the then-Prime Minister of Libya had an urgent request: help us build a new military force, he implored American officials, that can solidify a fledgling government’s legitimacy and buy us time to get our country back on track.

Back home, things were going badly. Just two years after the overthrow of dictator Muammar Gaddafi, the country was awash with heavy weapons. Militias, reluctant to give up power, had begun to turn their guns on one another. A separatist movement was gaining traction in the country’s east. And a year earlier, in 2012, Islamist militants had killed the US ambassador and three other Americans in Benghazi.

“We would like an alliance against terrorism,” Mr Zeidan told President Obama and other world leaders as he made his case.

Libya’s story in the past four years has been one of post-Gaddafi optimism quickly souring into today’s violent chaos. Along the way, the Obama administration’s role has come to symbolise the shortcomings of the West’s approach in the country.

Countries with the worst relations with neighbours Show all 8 1 /8 Countries with the worst relations with neighbours Countries with the worst relations with neighbours 1. Ukraine (score: 5.0) Getty Countries with the worst relations with neighbours 2. Syria (score: 5.0) Getty Images Countries with the worst relations with neighbours 3. Russia (score: 5.0) VASILY MAXIMOV/AFP/Getty Images Countries with the worst relations with neighbours 5. Lebanon (score: 5.0) AFP/Getty Images Countries with the worst relations with neighbours 11. Libya (score: 4.0) Countries with the worst relations with neighbours 12. South Korea (score: 4.0) PA Countries with the worst relations with neighbours 13. Israel (4.0) EPA Countries with the worst relations with neighbours 14. Iran (score: 4.0) Getty Images

US officials spent more than a year trying to develop military training but they were ultimately unable to come up with an efficient way to find, train and equip recruits. As the country became increasingly consumed by violence, the US government quietly abandoned its plan.

“There was plenty of blame to go around on all sides,” a senior US official said.

Benghazi residents and Libyan security forces gather around a burning car after an explosion killed the military prosecutor for Western Libya Youssef Ali al-Asseifar on 29 August, 2013 (AFP)

After Libyans rose up against Gaddafi in early 2011, inspired by the revolutions in neighbouring countries, Mr Obama committed US military power to ensuring that the dictator could not follow through on promises to destroy his opponents.

After five months of US, Nato and Arab airstrikes, rebels entered Tripoli in August 2011, signalling an end to the Gaddafi era. For the Obama administration, it was vindication of a different approach to foreign policy.

An early opponent of George W Bush’s war in Iraq, Mr Obama was determined to avoid another Middle Eastern quagmire. His administration would provide limited support to Libya but let neighbours such as Algeria, Egypt and European countries with historic links take the lead in safeguarding stability.

The Benghazi attacks, and the images of Ambassador Chris Stevens’s limp body being carried from a burned-out safe room, were a difficult turning point for the risk-averse White House.

Aid and diplomatic programmes were put on hold for months. The Benghazi attacks also crystallised another lesson for US officials: helping Libya achieve a modicum of security was paramount.

The White House seized on Zeidan’s proposal – which called for outside assistance in building a military force that could contain militias and form the core of a national army – as a low-cost, low-risk means to stabilise Libya.

Leaders from G8 nations endorsed Zeidan’s plan, which became known as the General Purpose Force (GPF).

The United States, the UK, Italy and Turkey together agreed to give their backing to a force of about 20,000 Libyan troops. The Pentagon would train and equip 6,000 to 8,000 Libyans in a programme lasting up to eight years.

Libyan Prime Minister Ali Zeidan speaks during a news conference with U.S. Secretary of State John Kerry (Getty)

Some in the US military were sceptical from the beginning, particularly at US Africa Command (Africom), based in Germany. No one even knew how many people the army comprised. A former State Department official remembered: “Africom said, ‘If we’re going to do this, we need to do it right. We need a real army.’ The problem was ... that was more than the US was willing to do.”

The White House declined to comment about the programme on the record.

US military officials were especially concerned about the difficulty of vetting recruits, most of whom would come from militias, and worried that someone might turn on US trainers. For safety, and because much of Libya’s military facilities had been damaged in the war, officials decided early on that the training would take place outside Libya. They settled on Novo Selo, a military facility in Bulgaria.

In summer 2013, Mr Obama concluded that the US had not done enough to keep Libya on track. “At that time it was seen as a country that had a chance to succeed,” said Derek Chollet, a former senior Pentagon official. With its small population, oil resources and proximity to Europe, there was no reason the nation should devolve into chaos.

Mr Obama asked his national security team to redouble its efforts, with a special focus on governance and security. But US officials were stuck. The White House wanted more activity, but it wanted Europe in the lead. The GPF was a priority but the White House wasn’t willing to risk more American lives in Libya.

Meanwhile, Libyan officials were struggling to find recruits who were ready to go overseas for training. Few Libyans were accustomed to the rigours of military life and the militias afforded better pay and more freedom than could be found in the barracks.

“It was like, ‘Why should I go to the army when I can have an easier life’ in a militia?’” one Libyan official said.

For months, US officials struggled to identify which Libyans were empowered to make decisions, sign documents and execute the tasks that were required for the training programme. “To get the same two interlocutors at a meeting two weeks in a row was nearly impossible,” an Africom source said. Virtually no Libyan official, no matter how senior, seemed to use a government email address. To track down key officials, foreign diplomats had to show up at Libyan ministries.

Air strikes rock the Libyan capital of Tripoli in 2011 (Getty Images)

Zeidan had spent decades living in Europe and elsewhere as an opposition activist. He hoped to ensure that Islamists, who had gained influence after Gaddafi’s ousting, would not monopolise decision-making.

“He presented very well and I think people were desperate to see something positive happen,” a senior US official said of Zeidan, noting his fluency in European languages and his liberal disposition.

It took US officials some time to realise how Zeidan’s proposals papered over internal political differences and how his increasingly precarious position affected seemingly routine tasks, such as making Libya’s first payment for the GPF programme.

For months, US officials waited for the first instalment on the $600m (£390m) project to be paid.

“Zeidan would say, ‘Oh no, we’re going to pay for it. The cheque’s in the mail,’” the former State Department official said. “But we didn’t get the cheque.”

“In retrospect, it’s clear the reason Zeidan was unable to sign documents was because, on one hand, he had people trying to stop [the creation of a national army] and second, he probably was not in command of the funding,” the senior US official said.

In March 2014, an Africom team met with Libyan officials in Tripoli to set up a system for gathering and vetting enough recruits to begin training that summer. But according to multiple US officials, the plans that Africom put forward were so elaborate they seemed certain to ensure the programme would never get off the ground.

“They turned a training programme into a massive programme that required all kinds of infrastructure, all kinds of security, all kind of bodies,” the senior US official said. “They were selling us a Cadillac when what we needed was a Ford.”

Allied countries moved faster. In the summer of 2014, more than 300 Libyan recruits began their course at Bassingbourn barracks in Cambridgeshire. A third were sent home in the initial months; others claimed asylum. In autumn, the entire group was sent home early after a number of troops, allegedly drunk, committed a series of sexual assaults in the nearby university city of Cambridge.

Almost all of those trained by foreigners scattered once they returned home, US officials said.

At the same time, fighting among rival factions intensified in Tripoli. The Africom team was pulled out in May as the embassy shrank to a skeleton staff. In July, amid what Secretary of State John Kerry called “freewheeling militia violence” near the US Embassy, the State Department hastily evacuated the remaining personnel.

The closure of the US mission consigned the GPF programme, like most other assistance initiatives for Libya, to a quiet death. “The impact has been that of a leaf on a pond,” the first senior official said.