An internet troll who falsely portrayed his brother-in-law as a Islamic State supporter, paedophile and would-be bomber of a Canning Town primary school has admitted the charges against him four days into his trial.

Sparked by the breakdown of his marriage, Shohidul Islam, 26, created fake profiles on Twitter, Facebook and YouTube aimed at destroying the reputation of Mohammed Razaul Karim, the brother of his estranged wife in Bangladesh.

He was charged with two counts of encouragement of terrorism, making a bomb hoax at a primary school, making indecent photos of children and possessing the Anarchist Cookbook.

Today, the fourth day of his trial, he dramatically changed his plea and admitted the offences.

Earlier this week, prosecutor Mark Weekes told jurors that charges arose from a “vicious digital and online campaign” against Mr Karim between late 2015 and early 2016.

Islam had married Mr Karim’s sister Fahmida Parveen Shuba in 2010 but she stayed in Bangladesh and by 2016, their relationship had begun to break down.

Mr Weekes said: “It may well be that failure of the marriage was one of the driving forces behind the defendant’s attacks on Mr Karim.”

Islam’s activities ranged from the “deeply nasty to the criminal” and included portraying his target as a supporter of Islamic State, he said.

Mr Weekes said: “That campaign had a number of different strands to it and from time to time they overlapped. First, the defendant attempted to portray Mr Karim as a radical Islamist extremist.”

Then in January 2016, the defendant, posing as Mr Karim’s uncle, allegedly emailed the Metropolitan Police website to falsely report his victim was planning to detonate a bomb at a primary school in Canning Town.

Islam went on to portray Mr Karim as a paedophile by creating a video and posted it using a fake social media profile on YouTube, the court heard.

The video entitled “Must watch child abuser, stay away from him” included an image of Mr Karim, the court heard.

Mr Weekes said: “The video suggested that he had been convicted in his ‘home country’ of child abuse in 2001, it suggested he targets children online, has been arrested several times in the UK because he abused so many children and says he should be deported from UK. It also says that he lives in east London.

“Needless to say, the allegation is entirely untrue.”

Mr Karim was alerted to the video by his uncle and he reported it to Plaistow police station.

Mr Weekes said: “Around the same time as this happening the defendant’s campaign against Mr Karim was to change tack slightly.

“It moved from the merely deeply nasty to the criminal. It sought to portray Mr Karim as a violent terrorist and a man who supported the aims of that most chilling of all terror groups, the Islamic State.”

Later the same month, Islam allegedly created pseudo indecent images of children and sent them to Mr Karim’s family.

The court heard he also created a profile on pornographic website X Videos in the name of Mr Karim and his wife and posted material on it.

When Islam was arrested at a job centre in January 2016, a digital copy of the Anarchist Cookbook was found on his mobile phone and further evidence on his laptop, jurors were told.

The text of the book included instructions on how to make a viable bomb, which Mr Weekes suggested, Islam may have planned to use as part of his ongoing campaign.

Islam, who lived with relatives in Hillcote Drive, Bradford, was remanded in custody and will be sentenced on Friday.

Judge Rebecca Poulet QC warned he would face a custodial sentence.