Libya, by almost universal agreement, is a basket case: a country torn apart by rival militia, competing versions of Islam, warlords and jihadists. The “unity” government based in Tripoli is rejected by the parliament and the army in the east. The hotchpotch of militias advancing on the Islamic State stronghold of Sirte will surely turn on one another when and if the town is taken.

Libya is home to an estimated 1,700 armed groups divided along ethnic, religious and political lines, and a staggering arsenal of cheap guns. It is one of the most fractured countries in the world.

But Libya was not always this way. For 18 years it was an independent, broadly unified, functional state with a constitutional monarchy and a booming oil