Barack Obama has described failing to prepare for post-Gaddafi Libya as the worst mistake of his presidency. But as described in our article, on 'Iraq - A brutal legacy of imperialist intervention', Libya is one of a long list of countries where imperialist intervention has ended in disaster for the local population.
In March 2011, the UN Security Council adopted a resolution backing military intervention in Libya, ostensibly to protect civilians from the regime of Muammar Gaddafi. MPs backed Prime Minister David Cameron's proposals for the UK to join the action by 557 votes to just 13. Shamefully, sections of the 'left' supported this intervention, arguing that it was the only way to protect the Libyan people from Gaddafi's repression.
At this time the 'Arab Spring' was at its height. The revolutionary wave had seen the overthrow of dictators Ben Ali in Tunisia in January and Mubarak in Egypt in February. Western powers had been taken unawares by the movements and lost these allies. In Libya they now saw the chance to stamp their authority on the situation and try to ensure the revolution would be diverted and would lead to a new regime that was amenable to their interests. No small consideration was the fact that Libya was the world's 12th largest oil producer, sitting on Africa's largest oil reserves.
At times, Gaddafi had claimed Libya was socialist, but it couldn't accurately be described that way. A redistribution of oil wealth had improved the lives of many Libyans, which until the 1960s had been one of the poorest countries in the world.
After the 1969 Gaddafi-led overthrow of the British-backed monarchy, the oil industry was nationalised.
However, workers had no control over the running of society. Gaddafi wielded dictatorial power and enriched himself and his children. The oil industry began to be re-privatised in 2003, just before Gaddafi announced the end of Libya's nuclear and chemical weapons programmes. This was part of an attempt to make a deal with the Western powers and get sanctions lifted.
The uprising against the Gaddafi regime began in the east, around Libya's second city Benghazi. Inspired by the revolutions in Tunisia and Egypt, the overwhelmingly young and educated population sought their chance to do away with Gaddafi and the ruling clique.
The international organisation that the Socialist Party belongs to, the CWI, described at the time the need to deepen the revolution by the building of workers' organisations such as unions and a party. We also called for democratic committees in order to coordinate the taking of power, and democratic workers' control of the country.
However, without an organisation around which workers and youth could organise their struggle, the leadership began to be assumed by defectors from the old regime and pro-Western politicians.
Fear of foreign rule, a well of support based on previous reforms, and the resurfacing of regional divisions, were among the factors which meant Gaddafi could not be easily swept away. Civil war ensued and forces loyal to the regime began a counter offensive against the revolutionaries, placing civilian lives at risk.
It was this that Nato powers seized on as an excuse to intervene. This was an utterly hypocritical action as they were doing nothing about attacks on civilians in Bahrain and Yemen which their allies, including Saudi Arabia, were responsible for. Instead, they were seeking to further their imperialist interests.
After 2003, European powers had largely rehabilitated Gaddafi, and Libya was an important trade partner and oil supplier.
In 2010, the EU had signed a deal to restrict the number of refugees reaching Europe, resulting in up to two million sub-Saharan Africans being trapped in Libya, many in detention camps.
American intelligence service, the CIA, had a close partnership with its Libyan counterparts, described by a senior US official as "especially productive".
Now that Gaddafi's rule was threatened, imperialist powers were hypocritically trying to pretend that they'd always opposed him. They looked to burnish their democratic credentials by claiming to support the revolution and thereby divert it in the hope of establishing an even 'friendlier' government.
Nato action included establishing a no-fly zone, airstrikes and the deployment of small numbers of special forces, including Britain's SAS. The tide of the civil war turned against Gaddafi, he was driven from power and eventually killed.
However, in the absence of an organised independent movement based upon the Libyan working people, Western intervention had further polarised the population and split the anti-Gaddafi forces. Previously posters had been put up by revolutionaries in Benghazi stating: "No to foreign intervention - Libyans can do it by themselves".
The revolution had been derailed and the chance for workers and youth to take control of their destinies had been lost. The country fractured into areas controlled by opposing forces.
A damning UK parliamentary inquiry in 2016 concluded that the result of intervention has been "political and economic collapse, inter-militia and inter-tribal warfare, humanitarian and migrant crises, widespread human rights violations, the spread of Gaddafi regime weapons and the growth of Isis in North Africa".
The images of slave markets have become emblematic of the desperate state of the country. People attempting to reach the Mediterranean in order to cross to Europe are at risk of capture and extreme exploitation by criminal gangs.
One former captive, speaking to Time magazine last year said: "The Libyans understood that if the EU doesn't want blacks to come, it means we are not valuable as humans. The EU is essentially rewarding these militias for abusing us, for raping us, for killing us and for selling us."
A second civil war began in 2014 between rival governments - the General National Congress based in Tripoli in the country's west and the House of Representatives based in Tobruk in the east, which is backed by the Libyan National Army (LNA) of General Khalifa Haftar.
A peace deal in 2015 officially saw the formation of a 'unity' government, the Government of National Accord (GNA) in Tripoli, which is recognised by the UN. However, Haftar's LNA remains hostile to it and the conflict is still ongoing.
While most of Libya is split between these two main forces it is a complicated and shifting patchwork quilt of control by different militias and tribal forces. For a time, this included significant territory held under the brutal, right-wing religious rule of the so-called Islamic State, although their influence is now severely diminished.
Despite the strength of Libya's regional and tribal conflicts, reflecting the fact that the country was only created in 1934 by the then Italian fascist colonial occupiers, the country's oil wealth also means that there is a continual struggle over who controls its oil exports.
Nato-led operations may have ended in 2011 but military intervention in Libya has not. The country remains a battleground between different, mainly regional, powers seeking to exert their influence.
The GNA has been backed by Qatar, Sudan, and Turkey while the LNA has had the backing of Egypt, United Arab Emirates and Saudi Arabia. Haftar, who once lived in CIA-supported exile in the US, has been backed by the French government, and recently had friendly contact with Trump.
This year there have been peace talks in Moscow and Berlin where the governments of eleven countries were represented, including the UK, as well as UN secretary general, António Guterres. However, General Haftar has not signed the ceasefire and his forces have now blocked oil exports.
Speaking at the Berlin conference, Boris Johnson hinted at possible further British involvement in the future, saying: "There's a case for us... sending experts to monitor the ceasefire."
The recent past is a stark warning however that the forces of imperialism will intervene only to pursue their own interests. Their 'support' for the uprising was really an attempt to control and limit the 'Arab Spring'.
Workers and the poor can only rely on their own class, including calls for international solidarity. If they are to take control of their own lives, they must be organised themselves, including building a workers' party with a socialist programme that can actually deliver on their aspirations.