German intelligence
© Wolfgang Rattay / Reuters
A Dusseldorf court has released a suspected Islamist who worked for the country's spy agency, according to media reports citing a local court official. He was arrested last year for gathering confidential data and planning a terrorist attack.

A Dusseldorf court freed the former agent for the German Federal Office for Protection of the Constitution (BfV) on Wednesday, media reported citing the court's spokesperson.

The court has dropped some of the charges, allowing the release of the 51-year-old suspect, but he is still to face prosecution for disclosing sensitive information, Deutsche Welle reports. The man will be charged only with attempted treason, according to the Local.

The man, whose name has not been disclosed, is a Spanish-born German national who was detained eight months ago after his interactions with Islamist militants via internet was exposed.

The infiltrator had worked for the intelligence agency for half a year when it was revealed that he had been collecting confidential data concerning the intelligence agency's operations and had been plotting an attack on the headquarters of his employer, BfV, "at the mercy of Allah," according to Der Spiegel.

In custody, the former agent revealed he had secretly converted to Islam and taken the job to warn "his religious brothers"about investigations.

The court's decision to free the detainee was partly based on the "impression" that he made during the hearings, Deutsche Welle reports, citing lawyers.

Following the suspect's arrest in November 2016, another "dark" side of the double agent was discovered during a search in his apartment. During the raid, security forces reportedly found gay pornographic films featuring the suspect as an actor.

The infiltrator was exposed just a month before the deadly attack on a Christmas market in Berlin in December 2016, which killed 12 people and injured 56 others.

In 2016, 20 Islamist infiltrators were reportedly exposed in the German Army, while 60 more were put on a surveillance list for having extremist views, Die Welt reported.

The soldiers were interested in advanced weapons and tactical training for future terrorist attacks.