Raheem Kassam was the right-hand man who rarely left Nigel Farage’s side during the election campaign. He was there for the drinking sessions, the ups-and-downs of Farage’s mood swings and even accompanied him on a series of steam-room trips in an attempt to stop the Ukip leader looking so sweaty on television. But less than a week after the election, Kassam was pressured out of his job in one of Ukip’s periodic bouts of infighting.

So what is his verdict on eight months at the heart of Farage’s empire? “I totally regret it. Every minute,” he says. “I don’t mean it was a horrible experience. But I’ve taken a big hit for nothing. The only good thing that’s come out of this are friendships ... But have I got anything else apart from looking at much of Ukip and thinking you are just a bunch of ragtag, unprofessional, embarrassing people who let Nigel down at every juncture? No.”

The public feuding kicked off after Farage decided to “un-resign”, going back on his promise to step down after he failed to win his target seat of South Thanet. In the fallout, Kassam’s detractors accused him of being a divisive Iago-type figure, dripping rightwing poison into Farage’s ear that harmed the party’s chances of winning over moderate voters. According to his critics, it was Kassam’s “shock and awe” strategy that led Farage to warn against foreigners with HIV using the NHS and claim there were half a million Islamist extremists among the migrants trying to cross the Mediterranean.

Raheem Kassam. Photograph: Graham Turner for the Guardian

But Kassam denies this was ever his game plan – his theory is that people were jealous that he got too close to the Ukip leader, to the exclusion of almost every other acolyte. By polling day, it was obvious to those following the Ukip campaign that the inner court of King Nigel had shrunk to Kassam, election strategist Chris Bruni-Lowe and his Kent press officer Sarah White.

“Egos got in the way at every point,” Kassam says. “Who do you think Nigel would call? It was always me. They absolutely hated that. But the truth of it was that we were always mopping up everyone’s messes.”

We meet at the Blue Boar, a regular haunt in Westminster, and the supremely confident Kassam seems unfazed. He has just returned from a holiday in the US, is back at his old job at the rightwing news site Breitbart and is ready to lift the lid on some bizarre and dysfunctional happenings that dogged Ukip’s campaign. Over a drink, he’s keen to outline what went wrong. The confusion over whether Farage should back a cap on immigrants? “It created an impression of chaos. There is no way to look at it and think: ‘These guys really know what they are talking about.’” The suspension of gaffe-prone Janice Atkinson as an MEP for allegedly trying to inflate her expenses? “Nigel wanted her out before that. She should have gone when she said ‘ting-tong’.”

The feuding between Farage’s personal team and officials at party HQ? “It was like a playground in there ... It got to the point where journalists would come into HQ and we’d have to lock certain doors because the people behind those doors were too embarrassing to be seen.” The manifesto? “It was a clusterfuck.” A particular party activist who remained in post despite a chequered history? “Disgraceful. The man is a racist, there is no doubt about it ... I don’t throw around racism often, I have a high threshold for it because I’m so anti-PC, but he is a definite racist.”

Kassam says this was the only example of racism that he encountered during his time in the party and that he faced more prejudice when he was a member of the Conservative party. The most surreal moment? When Louise Bours, the health spokeswoman, decided to resign in the middle of one of Farage’s rallies in a row over NHS spending. “Afterwards, I had to lock everyone out of the room and tell Nigel. I can’t repeat what he said then.” She was later persuaded to stay and the episode never became public.

He blames three senior Ukip figures for engineering his exit from the party and trying to orchestrate a coup against Farage – Patrick O’Flynn, the former economics spokesman, Suzanne Evans, the deputy chairman, and Douglas Carswell, the party’s only MP. This is a charge they all deny, but O’Flynn was stripped of his frontbench role and Evans of her responsibility for policy in the aftermath of the row. Kassam reckons Carswell will survive just another six months in Ukip because he is no longer useful, given that the party has turned down almost £1m of public funding due to him as an MP. “Douglas is not worth anything, he has no clout. He means nothing to us now,” he says.

Farage hears of his defeat in South Thanet on 8 May, with fellow contestants Will Scobie and Al Murray. Photograph: Bloomberg via Getty Images

On O’Flynn, he is equally scathing: “I’m sorry, but if you are Patrick O’Flynn and you have managed via your morning briefings to elicit a headline that says the EU is brainwashing our children through colouring books – OK, you tell me who is doing more damage to the party? And you know what the worst thing is? I went out to bat for those guys every time when they were in trouble.”

Kassam claims that even before the election he could see a “plot” coming and warned Farage to no avail. “I predicted everything that would happen – the Suzanne stuff, the Carswell stuff, the Patrick stuff – nobody listened to me,” he says. “It earned me a lot of credit with Nigel that I foresaw that.”

Not enough to keep him in the job, some might say, with the others still in the party. But Kassam claims he was not forced out of his role as Farage’s senior adviser, but instead chose to leave at the end of his contract in order to “bulletproof Nigel”.

His argument goes like this: the anti-Farage camp believed the Ukip leader was veering too far to the right and had become too toxic to lead an EU referendum campaign that was now going to happen under a Cameron majority government. As Kassam’s critics lined up, painting him as a malign Tea Party influence on Farage, he says he was confronted with the choice of trying to brave out the row or resigning temporarily before returning as part of the leader’s Brussels staff. As it happened, Kassam was on the way to see his old boss at Breitbart in the US at the time, and was offered his former job back on the spot. He downed a shot of vodka, and then made his way to the Sky News studio to start defending Farage and attacking O’Flynn, including accusing him of having “personal problems” live on air.

“In those situations it’s fight or flight. You can crumble or you can rise to the occasion. I was sitting there thinking: it’s fine. It’s just a job, I did my best. If I genuinely thought I’d let Nigel down in any way I would have been upset and distracted ... But basically I’ve formed a one-man human shield around Nigel. Every time they go for him, who will the journalists come to for background and quotes? I’m his forcefield at the moment. He knows it to be true to this minute.”

Certainly, the whole episode has not dented Kassam’s loyalty to Farage, whom he describes as his “hero”. He claims they still speak regularly, most recently the day before – about the content of his speeches, social media and just general chat. Not coincidentally, Farage has also just signed up as Breitbart’s new star columnist. So why is he speaking out now, and would Farage be unhappy about what he has to say to the media? “Probably. But that’s my prerogative. “I think Nigel’s had a rough time, unfairly. And I’ve had a rough time, unfairly. That’s why.”

Douglas Carswell and Nigel Farage in happier times. Photograph: Matt Dunham

The 28-year-old son of Muslim immigrants who live in Uxbridge, Kassam might not seem the most likely choice to become friends with the leader of Ukip, but he has a history of working for rightwing websites and the Henry Jackson Society thinktank. He says he first bonded with Farage when they met in the US and went on to have what is known in the Ukip lexicon as a number of “PFLs” – proper fucking lunches, defined by the number of bottles of wine that are consumed. After he was hired – despite warnings in the media about his “wild self-importance” – Kassam believes he became invaluable to Farage because he was one of the few people to stand up to him.

During the last six weeks of the election campaign, Kassam was dispatched to the target constituency to take charge as it became clear the Tories were throwing in more resources. He immediately moved into Farage’s flat in Ramsgate, which became a place where there was a wine glass stuffed with cigarettes butts, an electricity meter that kept running out of credit and Farage’s bed was a mattress on the living room floor. “It looked like a Damien Hirst exhibition,” he says with pride.

On a typical day, Farage would be up at 6am, bright and perky for a breakfast of kippers at a nearby hotel. “Then we’d rendezvous at the office and decide what we want to do for the day, which would involve some walkabouts and a lot of knocking on doors. Then we’d maybe hit a pub for lunch. Then more walkabouts and more canvassing. Then another pint around 5 o’clock, go out and do more evening canvassing. Then around 9, we’d go to The Smugglers [pub] for dinner or we’d go to La Magnolia [an Italian] and have a nice civilised meal.”

However, the entire Ukip team had failed to spot that Farage’s health difficulties – which led media commentators to note that the Ukip leader was tired and snappy at points in the campaign – were affecting his mood. “None of us realised he had back problems,” he says. “That was his fault. We all saw the way he looked during the Believe in Britain speech. I thought: ‘We’d been for a steam three days running so you don’t look sweaty. But you’re still sweating and look really uncomfortable.’ I couldn’t understand it.”

Farage finally spoke out about his agonising pain a few weeks before polling day, and decided to scale back his schedule and concentrate his time mostly on winning South Thanet. In the end, he lost by around 2,000 votes, having been convinced right up until the day itself that he was about to enter parliament on his seventh attempt.

Nigel Farage faces the media after defeat. Photograph: AFP/Getty Images

“We knew by 10 o’clock that we hadn’t done it,” Kassam says. “That morning, Nigel and I went to vote together, and we were both in good spirits. I was quietly confident, I knew it was so close ... But suddenly between 12 and 4 there were queues in Broadstairs, and I thought: Oh no, these people are not voting for us ... It got to around eight and the queues in Broadstairs hadn’t subsided and everywhere else had. I said that’s it. I had tears in my eyes and I was genuinely holding back tears for the next 48 hours. I don’t cry, but I was so sad, so deeply sad.”

While the results rolled in, Farage was asleep, while Kassam and Bruni-Lowe slept in 30-minute shifts to keep abreast of the news. In the morning, they accompanied Farage to the declaration, knowing that he had lost.

Within an hour, Farage had resigned, and Kassam still insists that the Ukip leader was relieved to be going – despite famously unresigning just four days later. Kassam will also not hear any criticism of the South Thanet campaign itself, which he boldly declares to have been the “single best campaign ever, ever in British politics, bar maybe the Bradford spring”. If it were not for the SNP, he says, the party would have won around five more seats.

Kassam also takes umbrage at the claims that he was responsible for Farage repeatedly bringing up the issue of immigrants with HIV using NHS resources. O’Flynn was fully onside, he says, and was present in the spin room after Farage’s television debate, ready to brief the press on the issue. He also disputes the idea that this in any way deterred potential voters.

“I don’t think there was anyone who was thinking of voting for us who was put off by that,” he says. “Don’t forget Labour voters aren’t who you think they are. They aren’t sat in Hampstead sipping Chateau Neuf Du Pape.”

Later on, Kassam returns to the theme. “Life is not a Michael Jackson song, you can’t heal the world,” he says. “I’d like to see any political party try and stand on that principle.”