Image copyright PA Image caption President Obama said he had "more faith in the Europeans...being invested in the follow-up"

David Cameron became "distracted" after the 2011 intervention in Libya, US President Barack Obama has said.

Speaking to the Atlantic magazine, he said the operation went as well as he had hoped, but Libya was now "a mess".

The article also said he had warned the PM the UK would have to pay its "fair share" and spend 2% of GDP on defence.

In response, Number 10 said there were "many difficult challenges" in Libya, while the White House said it deeply valued the UK's contributions.

Downing Street did not comment on President Obama's remark to the PM about defence spending, reportedly made before Chancellor George Osborne said the government would fulfil a Nato pledge to spend 2% of national income on defence last year.

In response to the interview, a spokesman for the US National Security Council said Mr Cameron had been "as close a partner as the president has had" adding that "we deeply value the UK's contributions on our shared national security and foreign policy objectives".

BBC North America editor Jon Sopel said the unsolicited statement put out by the White House suggested Downing Street had reacted angrily to the article.

"It's like we've seen a curtain drawn back on the unspun thoughts of President Obama, complete with frustration as well, and what we've seen tonight is the White House trying to close the curtain as quickly as it can," he added.

'Casualties averted'

The toppling of the Gaddafi regime in Libya - following UN-backed air strikes designed to protect civilians - led to a power vacuum and instability, with no authority in full control.

The intervention was led by the UK and France - and in his interview, Mr Obama reflects on "what went wrong", saying: "There's room for criticism, because I had more faith in the Europeans, given Libya's proximity, being invested in the follow-up."

Mr Cameron, he said, became "distracted by a range of other things". He also criticised former French President Nicolas Sarkozy, saying he had tried to claim the spotlight.

The former French president, he said, "wanted to trumpet the flights he was taking in the air campaign, despite the fact that we had wiped out all the air defences and essentially set up the entire infrastructure" for the intervention.

President Obama said the intervention "averted large-scale civilian casualties (and) prevented what almost surely would have been a prolonged and bloody civil conflict". But he added: "And despite all that, Libya is a mess."

He also criticised what he called "free riders" in the interview, saying European and Gulf countries were calling for action against Gaddafi, adding: "But what has been a habit over the last several decades in these circumstances is people pushing us to act but then showing an unwillingness to put any skin in the game."

'Like rats'

Despite efforts to support Libya's National Transitional Council, and the first elections in the country for decades, it rapidly descended into violence, with two rival governments and the formation of hundreds of militias, some allied to so-called Islamic State.

In January, Mr Cameron told MPs the "Libyan people were given the opportunity" to build a stable democracy - and it was a matter of "huge regret" they had not taken it.

He stressed that - unlike in Iraq - the post-conflict planning was locally driven.

"Gaddafi was bearing down on people in Benghazi and threatening to shoot his own people like rats," he said. "An international coalition came together to protect those people and to help the Libyan people, who then got rid of Gaddafi.

"And they had an opportunity to build what they said they wanted."

Responding to President Obama's interview, Downing Street said "coming to the aid of innocent civilians who were being tortured and killed by their leader was the right thing to do".

The government has tried to support stability in Libya and is "working hard to support the UN-led process to establish a stable and inclusive government that will allow them to build a peaceful future", a spokesman said.

"But ultimately a positive outcome for Libya is not just up to the international community - this process needs to be led by the Libyan people," he added.

The US National Security Council spokesman added: "With respect to Libya, the president has long said that all of us - including the United States - could have done more in the aftermath of the Libyan intervention."

He said the UK had "stepped up on a range of issues" including meeting the 2% commitment and pressing other Nato members to do the same.

Former Conservative Foreign Secretary Sir Malcolm Rifkind said it was "a bit rich" for the US president to single out the UK and France, as they had carried out more air operations in the Libya campaign than any other country.

Libya timeline

Image copyright Reuters Image caption RAF Typhoons wait to be serviced after their first mission over Libya in March 2011

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

20 February - Anti-Gaddafi rebels seize control of Libya's second city Benghazi

21 February - David Cameron, on a tour of the Middle East, condemns violence by the Gaddafi regime. Over the next few days he faces criticism over the government's handling of the evacuation of Britons from Libya

28 February: Mr Cameron asks the Ministry of Defence to "work with our allies on plans for a military no-fly zone" over Libya

2 March: Mr Cameron is forced to defend the no-fly zone plan after US Defence Secretary Robert Gates dismisses the idea as "loose talk"

14 March: Mr Cameron insists it is "perfectly deliverable" - and denies he is having trouble convincing other EU leaders, with the exception of French President Nicolas Sarkozy, of the need for one

17 March: The UN Security Council votes to impose a no-fly zone over Libya

19 March: The RAF begins bombing raids alongside French and US jets, with logistical support from several Arab nations

21 March: MPs vote to authorise UK military action, which is backed by then Labour leader Ed Miliband

21 August: Rebel fighters enter Tripoli. Mr Cameron cuts short his summer holiday in Cornwall to hold a meeting of the National Security Council and makes a statement outside Downing Street saying: "Gaddafi must stop fighting - without conditions - and clearly show that he has given up any claim to control Libya."

1 September: Libya's interim rulers meet world leaders in Paris to discuss reshaping Libya, as Gaddafi urges his supporters to fight on

15 September: Speaking in Benghazi's Tahrir square, Mr Cameron praises the way Libya's interim authority has taken charge but warns the "hardest part" is still to come

20 October: Gaddafi is captured and killed by rebel fighters in the city of Sirte