Image copyright AP Image caption Libya tumbled into chaos after the US and others intervened to protect civilians

US President Barack Obama has said failing to prepare for the aftermath of the ousting of Libyan leader Col Muammar Gaddafi was the worst mistake of his presidency.

Mr Obama was answering a series of questions on the highs and lows of his time in office on Fox News.

He said, however, that intervening in Libya had been "the right thing to do".

The US and other countries carried out strikes designed to protect civilians during the 2011 uprising.

But after the former Libyan leader was killed, Libya plunged into chaos with militias taking over and two rival parliaments and governments forming.

How Obama learned the limits of US power

So-called Islamic State (IS) gained a foothold, and Libya became a major departure point for migrants trying to reach Europe.

A UN-backed national unity government arrived in the capital Tripoli earlier this month but is waiting to take charge.

The leader of the faction ruling western Libya has threatened to prosecute any of his ministers who co-operate with the UN-backed administration, contradicting an earlier announcement the ministers would stand down.

President Obama gave the brief but revealing answer speaking to Chris Wallace:

CW: Worst mistake?

Obama: Probably failing to plan for the day after, what I think was the right thing to do, in intervening in Libya.

It is not the first time President Obama has expressed regret over Libya. He told the Atlantic magazine last month the operation went as well as he had hoped, but Libya was now "a mess".

In that interview, he also criticised France and the UK, in particular saying British Prime Minister David Cameron became "distracted" after the intervention.

It was a rare rebuke for a close ally and one which BBC correspondents at the time said angered Downing Street.

Image copyright Reuters Image caption Rival militias have been fighting for control in Libya

President Obama told Fox that his biggest accomplishment in office was "saving the economy from the great depression".

He said the best day of his presidency was when he passed the healthcare reforms. The worst, he said, was responding to the mass shooting at Sandy Hook elementary school.

Mr Obama discussed his legacy in a BBC interview last year, saying his failure to pass tighter gun control laws was the biggest frustration of his presidency.

Libya timeline

Image copyright Reuters Image caption Col Gaddafi was killed during the 2011 popular uprising

February 2011: Protests against Colonel Gaddafi's regime erupt in Libya

March 2011: UN Security Council authorises a no-fly zone over Libya and air strikes to protect civilians

October 2011: Gaddafi is captured and killed by rebel fighters

2012: Splits emerge as the transitional government struggle to rein in local militias

September 2012: The US ambassador and three other Americans are killed when Islamist militants storm the consulate in eastern Benghazi

June 2014: Disputed elections are held. Two governments are formed: one in the capital Tripoli, the other UN-backed administration in eastern Torbruk

January 2015: The UN announces a new interim government but it is yet to take charge