It is revealing to read Foreign and Commonwealth Office travel advisories addressed to British citizens about security, or the lack of it, in countries where the Government otherwise plays down the dangers. I used to enjoy reading scary FCO advisories about Iraq eight or nine years ago, warning travellers not to set foot there because of the ferocious and pervasive violence. This was sharply – and at times absurdly – at odds with Tony Blair and his government, who were berating journalists for exaggerating the dangers, and claiming that 14 out of 18 Iraqi provinces were at peace. Spouting the same optimistic drivel, Blair would turn up in Baghdad's Green Zone on a "surprise" visit wearing a flak jacket after flying from the airport by helicopter.

Foreign political leaders are now similarly making "surprise" visits to Libya, as David Cameron did in January – when they dare to go there at all. Only a year ago, Nato action in Libya in 2011 in support of the rebels was being held up as a successful foreign military intervention that might usefully serve as an example of what the United States, Britain and France should do in Syria. Not many still believe this, but those who do might like to look at the latest FCO travel advisory for Libya last updated on 22 October, and accompanied by a useful map. This divides Libya into two zones, denoted by dark and light shades, to illustrate the different levels of insecurity.

The news is not good for potential travellers: the darker shade covers 85 per cent of Libya including the oilfields, the Sahara, and a large part of the coastline – areas where the FCO advises "against all travel". At the top right and top left corners of the map are areas marked in a lighter shade which include Tripoli and the coast road as far as Misratah in the west and the bulge of Cyrenaica in eastern Libya. Here the FCO merely advises "against all but essential travel". But travellers need to study the map and accompanying text very carefully because there is a brown smudge over Benghazi, the capital of Cyrenaica, indicating that the FCO regards the city as too dangerous to visit. In fact, anyone contemplating a tour of this part of Libya should note that the FCO map gives the impression that the whole of Cyrenaica is safe enough for "essential travel", but the text speaks less confidently stressing that the traveller should stick to "coastal areas from Ras Lanuf to the Egyptian border, with the exception of Benghazi and Derna". Derna holds the record for dispatching more foreign fighters and suicide bombers to the war in Iraq than any other town in the Muslim world.

Download the new Independent Premium app Sharing the full story, not just the headlines

There is no doubt that the FCO has got it right. Libya has become one of the most dangerous parts of the world: 10 days ago, assassins shot dead the commander of Libya's military police, Ahmad al-Barghathi, as he left a mosque in Benghazi. In the past year there have been 80 such assassinations of senior military and police commanders. The killing of al-Barghathi happened soon after Libya's Prime Minister, Ali Zeidan, was briefly kidnapped from his hotel in Tripoli without a shot being fired by his guards in his defence. Libya's oil production is down to 600,000 barrels a day after almost ceasing during the summer because the militiamen who guard the oil facilities have seized the ports in the east.

Some of this could be dismissed as post-revolutionary chaos inevitable after the overthrow of Gaddafi, but that took place two years ago. And the security situation is getting worse, not better, with 225,000 Libyans registered as members of the militias that are armed and paid by the government. The idea was that these gunmen, only about a tenth of whom fought against Gaddafi, would gradually be incorporated inside state security institutions and so brought under government control. In practice, the opposite has happened with the power of militias and their commanders becoming institutionalised; it is often superior to that of the regular army and police. In Cyrenaica, a former rebel leader, Ibrahim al-Jathran, leads 20,000 militiamen who control facilities producing 60 per cent of Libya's oil.

The militias and local warlords are filling the vacuum left by the fall of Gaddafi. The victorious civilian opponents of the old regime ascribe their failure to establish stable government to the lack of state institutions, which had withered under Gaddafi's rule. There is something in this, but a better explanation is that Gaddafi was primarily overthrown by Nato using its air power, with the Libyan militias acting as a mopping-up force. When Gaddafi fell his enemies did not have the political or military strength to replace his regime, or solve economic problems which the old regime could not resolve. Unemployment remains at 40 per cent and young men without a job see no alternative but to carry a gun and join a militia.

But Libyans are not alone in this. Without exception, national liberation and opposition movements in the Middle East, North Africa and the Caucasus have failed to replace police-state dictatorships and foreign occupations over the past 20 years with something better. Chechen nationalists fought heroically against the Russians in the early 1990s, but turned into racketeers and Islamic fanatics by 1999. Saddam Hussein's rule was a disaster for Iraqis, but the Iraqi opposition in power was even greedier, more corrupt and dysfunctional than the old regime.

What caused these failures? Both rebels and their foreign supporters failed to think through what they would do with power when it was won. They had long demonised Saddam, Gaddafi and Assad as the cause of all their countries' problems. They believed all would be well once these rulers had gone. Believing much the same thing, the foreign media was perplexed as to why the problems of Iraq and Libya did not evaporate after the removal of old leaders.

Nationalism and socialism – or at least state control of the most important enterprises – were the political and social cement of states like Iraq, Syria and Libya under their old leaders. Corruption and privatisations to the benefit of ruling families had dissolved these bonds, but triumphant opposition movements had nothing to put in their place aside from sectarian or tribal solidarity. Libya may be failing to create a state demonstrably preferable to the old, but the same is sadly true of all opposition movements in the region.