Media playback is unsupported on your device Media caption "If the prime minister... makes a statement about your tax affairs, that is going to need dealing with."

Jimmy Carr has said the furore over his tax affairs in 2012 could have ended his career.

The comedian hit headlines over his involvement in a tax avoidance scheme which the former prime minister, David Cameron, called "morally wrong".

"When you're in the middle of that [it's] like, 'could this be a career-ender?'" he told BBC Radio 4's Desert Island Discs.

"I guess with something like that, that's the worst case scenario."

He added: "Even worst case scenario, I've had a pretty good run in showbiz terms. I've been at the same level for probably 12 years now - that's very lucky to have a long, sustained career in showbiz.

"So it's going to disappear at some point."

Image caption The comedian was speaking to Desert Island Discs host Kirsty Young

The star was widely condemned for taking part in the K2 tax avoidance scheme - something he said was "a terrible error of judgement".

At the time, Mr Cameron was attending the G20 summit when he broke off from discussions to comment on the affair.

"If the prime minister breaks off from the G20 summit in Mexico - in a meeting with the 19 most important people in the world - and he comes out and makes a press statement about your tax affairs, that is going to need dealing with," Carr said.

"You've got to get out in front of it, and also you need to own it.

"Sometimes when footballers are involved in these things, people go: 'Well he probably didn't know what was going on and he got advice'.

"I don't think anybody was buying that line with me, I think people thought: 'He probably knew what he was doing'."

Image caption Carr has since paid all the tax and said after the event he would "conduct my financial affairs much more responsibly"

Carr said a financial adviser had told him of the scheme: "If someone comes to you and says, 'Do you want to pay less tax? It's totally legal, you can do this thing, and if it ever comes up you just have to pay them' - you go, 'yeah, fine, great'.

"In the end you make good and say: 'Right I'll pay every penny of tax I ever owed.'"

The comedian said the whole incident taught him that "when you have a friend in trouble, call".

"That was the big lesson.

"If you have a friend and they're in the paper or they're having a problem with something and you don't know what to say, or someone's just died or someone's been diagnosed with something, call them."

Carr was thought to be one of more than 1,000 beneficiaries who sheltered some £168m from the taxman each year through the K2 scheme. He has since paid all the tax.

Desert Island Discs is on BBC Radio 4 on Sunday, 5 March at 11:15GMT.

Follow us on Twitter @BBCNewsEnts, on Instagram at bbcnewsents, or if you have a story suggestion email entertainment.news@bbc.co.uk.