Over recent weeks, the United Nations special representative in Libya, Bernardino Leon, has been patiently trying to bring the country’s feuding politicians together.
The hope is that, if they can agree to cooperate with each other, a civil war might yet be averted.
Most observers, while wishing him well, thought it an impossible task.
Nonetheless, he has doggedly pushed ahead, organising meetings between politicians in Ghadames, Algiers and, latterly, Skhirat in Morocco.
Now, it seems, the first tentative signs are emerging that he might succeed.
The problem is that, ever since June last year, Libya has had two governments – one in Tripoli and one in Tobruk.
The Tripoli government is the remnant of Libya’s very first elected government in July 2012, the General National Congress (GNC).
It was supposed to be an interim body with the primary responsibility of drawing up a constitution under a mandate that was to last until February 2014.
In the event, the legislature failed to master a worsening security situation with a proliferation of militia groups.
Tensions between Benghazi in the east and Tripoli in the west – and nationalists and Islamists – intensified in the face of an impotent national army.
The divisions were made more profound by the legacy of the regime of Muammar Gaddafi, separating tribes and regions from each other.
The constitution-drafting process stagnated because of disputes about who should participate and, in desperation, new legislative elections were called.
In the June 2014 election only 15 percent of the electorate came out to vote so the outcome was rejected by Libya’s moderate Islamists, displeased with their poor showing.
They and their Misrata militia allies in the Libyan Dawn movement insisted that the rump of the GNC was the legitimate legislature. The new legislative body, the House of Representatives (HoR), supported by militias from Zintan, decamped to Tobruk.
There it adopted the remnants of the national army, appointing General Khalifa Haftar who had announced the formation of an anti-Islamist movement, Libya Dignity, some months before, as its commander.
Each legislature has appointed its own government, with Omar al-Hassi as premier for the GNC in Tripoli and Abdullah al-Theni as prime minister for the HoR in Tobruk.
Both governments have bid for international recognition – a struggle that the HoR appears to have won – as they have struggled to control Libya’s all-important oil industry and its central bank.
They also had to confront intensifying political and religious extremism as the country collapsed into chaos and towards civil war.
It is a measure of the success of the UN’s envoy to Libya, that he has persuaded both sides that – at least in principle – Libya needs a unitary government if it is to survive. This means that the GNC might have to accept last June’s election after all.
Of course, there is a very long way to go before Libya’s crisis really abates and not everybody accepts the United Nations initiative.
Indeed, even if they do accept the principle of a unitary government they do not necessarily agree with international opinion.
This was most recently enunciated by UN Secretary-General Ban Ki-moon.
During a meeting with HoR representatives, on the sidelines of the Sharm al-Sheikh summit, he confirmed that they were considered the legitimate representatives of Libya.
The secretary-general is not prepared, however, to have a UN arms embargo on Libya removed.
Nevertheless, splits are beginning to appear in both camps as they contemplate the consequences if no solution is found.
Thus the GNC has tired of the Hassi government, which it accuses of financial mismanagement after fourteen of its ministers threatened to resign unless the prime minister was replaced.
The premier, however, has refused to step down unless the militias that back the GNC say he should resign.
They too are split between pragmatists and Islamists, with the latter insisting that they are the sole true repository of legitimacy in the country and forced Hassi to step down.
The HoR does not enjoy universal support and many hold Tobruk responsible for encouraging Egypt and the UAE to intervene militarily against Libya Dawn.
Theni, too, wants to step down – and denies that he ever sought political power while complaining of constant interference from political figures and tribal leaders.
He has rejected complaints in the HoR that his government has failed.
The premier has openly called for the GNC to accept the need for a single government for the country and promises to step aside if it does so.
The harsh reality, however, is that the real power of decision lies with those who have the weapons.
General Haftar, for example, is unwilling to give up his campaign against extremists, even if his forces are at stalemate in Benghazi and Derna.
Libyan Dawn’s commanders are equally unwilling to abandon their campaign against Zintan and the Warshafanna.
Yet, even here there might be hope. Both Libya Dawn and Libya Dignity recently agreed to withdraw from Libya’s major oil ports at Ras Lanuf and es-Sider.
Each had been seeking to control the cities in order to confront extremists linked to the Islamic State group in Sirte.
If they can agree over that, then a solution to Libya’s chaos might really be possible.
By George Joffé.