Image caption Mr Johnson discussed Libya's future with Field Marshal Khalifa Haftar, who heads Libya's National Army

The removal of Colonel Gaddafi in 2011 has been a "tragedy so far" for the people of Libya, Foreign Secretary Boris Johnson has said.

He told BBC Radio 4's Today programme that "we were way over-optimistic" about Libya's future, adding that the elections of 2014 "made things worse".

His comments came after a two-day visit to Libya, where he urged rival parties to compromise and unite the country.

Mr Johnson pledged £9m to help tackle people trafficking and terrorism.

In a landmark meeting, Mr Johnson became the first senior Western politician to visit the Libyan military commander Field Marshal Khalifa Haftar on the ground at his home base near Benghazi.

'Selfish interests'

He said Field Marshal Khalifa Haftar, who controls eastern Libya, has pledged to give up military rule if he becomes the country's president.

Mr Johnson said he pushed the point of political compromise to Libyan politicians.

He said: "I think the politicians need as it were to suppress their own selfish interests, compromise for the good of the country and get behind the UN plan."

But he said he told Libyan politicians to learn from UK Prime Minister Theresa May's mistake - and not to hold an election before they were ready.

Oliver Miles, the UK's former ambassador to Libya and deputy chairman of the Libyan British Business Council, said that Mr Johnson's visit was a "useful and good follow-up" to the French president's meeting during which Field Marshal Haftar and his rival, the UN-backed Prime Minister Fayez al-Sarraj, agreed to a ceasefire.

But he told the Today programme it was "misleading" to think of Libya as divided into two parties, adding that it is much more divided than that.

Though it is six years since the removal of Col Gaddafi, he said: "There's been a complete breakdown of government authority - Libya is not in a state of civil war - it would be more accurate to describe it as in a state of anarchy.

"There is no government authority who runs the country and there are large parts of it where there is no government at all".

Shortly after Col Gaddafi was overthrown in 2011, thousands of Libyans turned out to cheer former Prime Minister David Cameron and then-French President Nicolas Sarkozy in Benghazi - hailing the pair as heroes for their support.

Media playback is unsupported on your device Media caption Former PM David Cameron was greeted as a hero by jubilant Libyans in 2011

Field Marshal Haftar's forces control much of eastern Libya and he is seen as a key player if Libya is ever to be united, something the UN-backed government of national accord has failed to achieve.

While there have been questions about whether Field Marshal Haftar would ever allow his forces to be subject to civilian control, the foreign secretary said he had been given at least one assurance.

Mr Johnson told the BBC earlier: "We are very clear, and so is Ghassan Salame, the UN special representative, that there has got to be civilian leadership in this country."

Image copyright .

Adding that while that does not mean there cannot be a role for Field Marshal Haftar, Mr Johnson said he accepted that were he to stand and be successful, "then he could not continue in his military role".

After visiting the many different sides of this deeply divided country, Mr Johnson said he was encouraged and that there was a chance of a political deal.

But he said other countries with different ideas about Libya's future should unite behind a new UN plan expected to be announced next month.

"A secure and stable Libya, better able to deal with the threat from terrorism and the challenge of migration, is firmly in the UK interests," Mr Johnson said.

"The Libyan people need a stable state that can meet their fundamental economic and security needs.

Adding that all sides needed to "compromise and work together", Mr Johnson said only a united Libya could "defeat the terrorists and smuggling networks who are exploiting the instability".

Though Mr Johnson did not say which countries should unite behind the UN, Mr Miles told Today: "I hope he had in mind the fact that the United Arab Emirates and, to some extent, Egypt have been supplying arms - contrary to the UN embargo to Hafta and his forces.

"And [there are] allegations that Qatar and Turkey have also been supplying arms to the other sides. I think that we and the other 'big boys' in the UN, the Security Council, should be stamping this out because I don't think it's helping a solution."

The BBC's James Landale, who is travelling with the foreign secretary, said the visit highlighted just how insecure Libya remains.

Analysis: Why Johnson feels he must fix Libya

Image copyright PA Image caption On Wednesday, Mr Johnson met members of the Libyan coastguard, who were trained in the UK

By BBC diplomatic correspondent James Landale in Benghazi

In the naval port in Tripoli, one is reminded of the different roles Britain has played in Libya in recent years.

In one dock lies the wreck of a frigate sunk by the RAF in 2011. It rests on its side, a rusting symbol of David Cameron's decision to use military force against Colonel Gaddafi's regime.

In another dock is a handful of coastguard vessels whose crews were partially trained by British Marines to help tackle the trafficking of migrants.

As Boris Johnson visited the port, it was clear both the scale of the problem Libya faces and the lack of resources it has to deal with it.

Read James' full analysis

On Wednesday, 11 of Field Marshal Haftar's soldiers were beheaded by the so-called Islamic State group in the south of the country.

And in Benghazi, Mr Johnson was only able to hold his meetings within the safety of Field Marshal Haftar's compound or the well-defended airport.

During Wednesday's meeting with Libya's unity government prime minister Fayez Sarraj in Tripoli, the foreign secretary said the UK would give the country more than £9m to bolster efforts to combat "terrorists, gun-runners and people traffickers".

Mr Johnson said Libya was the front line in Europe's struggle against illegal migration and terrorism.

The aid package includes £4m to support the removal of mines and improvised explosive devices, particularly in the city of Sirte, a former IS stronghold from which the militants were removed by Libya's military earlier this year.