Image copyright Reuters

Three years after Western military intervention helped topple Col Muammar Gaddafi, many believe Libya is rapidly turning into a failed state. There are two rival governments, and the parliament elected in June has been forced to flee from hostile militias - to a grey concrete 1970s hotel near the Egyptian border.

They've been chosen to rule a vast country that holds Africa's biggest oil reserves.

They represent the democratic future of a land the world helped free from tyranny.

But three years after the fall of Gaddafi, Libya's new members of parliament can't get on with the job. They're trapped in a grey, concrete hotel in a remote port 1,000km (620 miles) from the capital, Tripoli - fighting a lonely battle, they believe, against the forces of militant Islamism.

Tobruk, a town of about 120,000 people on the far-eastern edge of Libya, is now one of the last toeholds of the internationally-recognised authorities. Militias attacked Tripoli in July, forcing the newly-elected parliament to flee.

The legal government was even forced to hire a Greek car ferry which moored in Tobruk harbour to house officials, activists and their families. They had fled death-threats in their hometowns.

Media playback is unsupported on your device Media caption A Greek car ferry temporarily housed officials and activists, but has now left

"It hasn't been the easiest of parliaments to establish," admits MP Salah Sohbi. Elected for Zintan in the west of Libya, he's a mild-mannered man in a neat grey suit who used to work at the British cultural centre in Tripoli.

He and his family had to be smuggled out of Tripoli in late July to escape the militias. He took refuge in the mountains, and was later flown to Tobruk. But his story's not the most dramatic.

"We have one of our colleagues, her son was shot twice," he says. "Another, her father was kidnapped. Another, he had four rockets launched into the middle of his house with his whole family in it. We have a colleague whose car was hit by a grenade. There's nothing that can happen, that didn't happen to us."

Now he and the other MPs spend their days pacing the overblown 1970s lobby with its huge cream leather armchairs, or drinking endless cups of coffee by the pool overlooking the Mediterranean.

Image copyright Reuters

Late into the night they hold parliamentary sessions in the hotel's conference hall.

But it feels as though they're in denial - wrangling bitterly over new laws and government appointments for a country in chaos.

Their parliament and government are the only ones recognised as legitimate by the UN, but within Libya they control none of the three key cities:

In Tripoli , the old parliament - the General National Congress - has continued to sit. It's even appointed its own rival government.

, the old parliament - the General National Congress - has continued to sit. It's even appointed its own rival government. Benghazi , the second city and headquarters of the 2011 Revolution, is largely in the hands of Islamist fighters, some with links to al-Qaeda. There are daily assassinations of officials, journalists and social activists.

, the second city and headquarters of the 2011 Revolution, is largely in the hands of Islamist fighters, some with links to al-Qaeda. There are daily assassinations of officials, journalists and social activists. Misrata, the third city and main port, is also loyal to the Tripoli authorities. Its militias keep them in power.

Meanwhile Derna, the next town along the coast from Tobruk, has declared itself an Islamic caliphate. It's a no-go zone for any government official.

It's all a far cry from the triumph of the revolution three years ago, when Gaddafi was eventually overthrown after a Western-led bombing campaign to protect the revolutionaries.

Image copyright AFP Image caption An anti-Gaddafi protester in Tobruk in February 2011

The French and British leaders, Nicolas Sarkozy and David Cameron, were cheered by jubilant crowds when they visited Benghazi in September 2011.

"You showed the courage of lions - and we salute your courage," Cameron said. But those lions - Libya's revolutionary militias - failed to disband. Since then, they've wrought havoc in the country, regularly besieging parliament, occupying ministries, once even kidnapping the prime minister.

Everybody sang the values of the revolution, but no-one ever sat down and discussed what these values were Salah Sohbi, MP

Some militias fight largely for the interests of their own town or region. But some are allied to Islamist political groups including the Muslim Brotherhood.

The current crisis was triggered when Islamists lost the elections in June, and militias from Misrata and other towns moved in to besiege the capital. The old parliament says it refuses to recognise the new one because there's been no formal hand-over ceremony. But with Tripoli and Benghazi controlled by the militias, a hand-over's hardly possible.

"Everybody sang the values of the revolution, but no-one ever sat down and discussed what these values were, and I think this is where we lost a trick," the new MP Salah Sohbi says.

"Some countries backed the Muslim Brotherhood because they thought these guys are OK, they're Islamists but they are moderate Islamists who have shown a clear distance from the Jihadists. And that is where the mistake happened."

The Tobruk-based parliament has labelled its Tripoli rivals as "terrorists". It's a charge that angers them. "We are still safeguarding all the principles of the 17 February Revolution (that overthrew Gaddafi)," says Omar al-Hassi, the prime minister appointed by the old Tripoli parliament.

Image copyright AFP Image caption Omar al-Hassi was sworn in by the rival parliament in Tripoli

He says he opposes the Tobruk authorities because they include some officials and politicians who once served Gaddafi.

If the Islamic militants take over Libya one day, what will happen? ... Crete can be seen from here on a clear evening Salah Sohbi

But al-Hassi admits his forces in Benghazi are allied to jihadi groups including Ansar al-Sharia, listed by the US as a terror organisation - it took part in the attack on the US consulate in Benghazi in 2012 in which the ambassador, Christopher Stevens, was killed.

"There are two forces there now. Some are Ansar al-Sharia - and some are revolutionaries from 2011," he says. "They fought together then, and they're fighting together now."

That apparent alliance worries not just the new MPs in Tobruk, but also many ordinary Libyans. Fares Labedi is a young oil engineer who believed the revolution would bring freedom and new jobs to a country where he and many of his friends were unemployed.

Today, he's still jobless - and he thinks life was better in some ways under Gaddafi, when at least there was security.

"I am not thinking about a job. I am thinking about being safe," he says. "If I want to go from Tobruk to Benghazi, I have to think 100 times. Jihadists are distributed all over Libya. They will catch me because I am from Tobruk."

His brother Fakhri has a job at an oil plant at Ras Lanuf, more than 500km west of Tobruk, but he won't return there because he fears he could be kidnapped on the way there and even beheaded.

Libya is splitting, he says: "One part with the army and police, and other part with the Islamic groups… Maybe we will fight those groups forever."

Image copyright ALAMY Image caption There are no flights out of Tobruk and the roads are unsafe because of hostile militia

The Libyan conflict has already become in part an international proxy war between competing power blocs in the Middle East. Diplomats say two anti-Islamist states, Egypt and the United Arab Emirates, have given military backing to the Tobruk-based authorities. Qatar and Sudan, on the other side, are accused by the elected authorities of backing the Islamist rebels - though they deny it.

Foreign diplomats have been trying to broker peace talks between the two sides - and some believe a conflict that's rooted at least partly in Libyan tribal and regional feuds can eventually be solved by compromise.

More from the Magazine

Image copyright Other

"The police station on the other side of the road was set on fire. The policemen climbed on to the roof, which was the same height as my apartment building. I stared at them across the street and they stared back at me.

"I had no power and no water. The food I had left over was gone in a day or two. I rationed the little water I had for four or five days, then it was gone. So I started drinking out of the toilet."

Alex Owumi: 'I played basketball for Gaddafi'

But the MP Salah Sohbi, like most of his colleagues in Tobruk, is simply demanding that the Tripoli forces hand over their weapons and surrender.

If they're not defeated, he believes, the whole world faces an extremist threat in Libya even greater than the one from Islamic State militants in Syria and Iraq.

"Let's look at the worst case scenario," he says, as we gaze out across the sparkling Mediterranean from the cramped hotel room that doubles as his parliamentary office.

"If the Islamic militants take over Libya one day, what will happen? It's two hours (across the sea) from here to Italy, Crete can be seen from here on a clear evening… If someone has the means to deliver rockets, the means to deliver destruction to Europe, they can do it from this side if they have control."

In small, isolated Tobruk, they believe the West must be blind not to see that danger. Western diplomats are trying to broker peace talks in Libya - but there's been little progress yet. And Western governments, now preoccupied with Syria and Iraq, aren't keen on further military involvement in the country.

The strategic black hole that's opening up on the southern shores of the Mediterranean is unlikely to be filled with a working state any time soon.

You can listen to Libya: Last Stand Against Jihad on the Assignment programme on the BBC World Service this Thursday, or watch it on Our World on the BBC News Channel on Saturday or Sunday, or on BBC World Friday-Sunday. You can also catch up on the BBC iPlayer.

Subscribe to the BBC News Magazine's email newsletter to get articles sent to your inbox.