Barack Obama has accused David Cameron of being “distracted” in the aftermath of the invasion of Libya – contributing to the current deadly “mess” in the north African country.

In a wide-ranging interview with The Atlantic magazine the US president partly blamed Britain and France’s leaders for the chaotic situation in the country.

US and British airpower helped oust dictator Muammar Gaddafi from power in 2011 – but an apparent lack of a workable post-conflict planning has seen the Isis militant group take hold in the country’s central costal areas.

David Cameron was accused of being distracted by other things (David Cameron at Prime Minister's Questions)

The internationally recognised Libyan government does not now control the capital Tripoli and various Islamist groups and local fighters control scattered regions and municipalities.

UN attempts last year to form a national unity government re-uniting the country have so far failed.

The so-called Islamic State controls the central port of Sirte, the birthplace of Muammar Gaddafi and a former hold-out of regime loyalists.

Fire rises from an oil tank in Ras Lanuf, Libya. Attacks against Libya's biggest oil terminals in recent weeks have been lethal and sustained (Reuters)

Mr Obama told the magazine that Mr Cameron had stopped paying attention to the conflict after becoming “distracted by a range of other things”.

In March 2011 coalition jets started started enforcing a no-fly zone above Libya.

The no-fly zone intervention came to an end in November 2011, months ahead of the London Olympics and after a summer of rioting in London.

The president also reportedly told the magazine that in private he referred to the conflict as a “s*** show”

Violence and instability in Libya

He also recalled telling Mr Cameron that Britain had to pay its “fair share” on defence spending and meet a 2 per cent Nato spending target.

Last year a book recounting the recolections of Tory chairman Michael Ancram said the White House had felt "f***ed over" by the PM's approach to Libya.

In December 2015, years after the intervention, Mr Cameron told the Spectator magazine that Libya was “better off without Gaddafi”.

“What we were doing was preventing a mass genocide. Then, as you say, the coalition helped those on the ground to get rid of the Gaddafi regime and it’s very disappointing that there hasn’t been an effective successor regime,” he said.

“We did a lot to try and help it, I remember taking the Libyan Prime Minister—as then was—to the G8 meeting in Northern Ireland, getting lots of support but the Libyan political leadership up until now—although there have been some good developments overnight—haven’t been able to put together a comprehensive government.”