Image copyright CPS Image caption Aidan James posted this photo of himself in Iraq to Facebook in August 2017

Aidan James, a British man who fought with a Kurdish militia against the Islamic State group, has been convicted of attending a place used for terrorist training following a retrial.

He was the first British anti-IS fighter to be convicted of such an offence.

But a number of people - including two fellow Britons who fought in Syria - have asked why James was charged at all, when the group for which he ultimately fought - the YPG - had been a central Western ally in the battle against IS.

This issue - and how his actions could be defined as terrorism - loomed large over the case.

In remarks ahead of the first trial, which can be reported for the first time, Mr Justice Edis - who presided over both trials - said he was "uneasy" about the prosecution.

He added that no one had explained why James was treated differently to other Britons who joined Kurdish militias.

Half-way through his first trial, James was cleared of the main terrorism offence - that he prepared for acts of terrorism by training in the UK, acquiring equipment, communicating with others and travelling to Iraq.

The judge said he had "no case to answer", leaving two charges relating to camps in Iraq and Syria.

James was charged in February last year after returning from the Middle East and has been remanded in custody ever since, spending time in a wing at the maximum security HMP Belmarsh housing IS supporters.

Before flying home, a police officer had told James that "nobody is going to accuse you of being a terrorist".

The officer had assured him: "There are loads of people like you who have come back from Syria and to the best of my knowledge none of them have been charged."

Image copyright CPS/PA Image caption James flew from Manchester airport to Iraq in August 2017

James, who has a history of mental illness, travelled to the region in August 2017 after deciding he wanted to combat the "evil" IS.

He first spent time at an Iraqi refugee camp, at which Kurdish militia the PKK was present, and later at a Syrian YPG training facility.

Unlike the YPG militia for which he ended up fighting, the PKK is classed as a terrorist organisation by the UK. Fellow NATO member Turkey regards both as terrorist groups.

The YPG is the principle component in the Syrian Democratic Forces, which received direct support from Western special forces and the RAF during the struggle against IS.

Earlier this year, the then-foreign secretary praised the "incredible courage" of its Kurdish fighters, saying that success would "not have been possible" without them.

Shortly before the retrial, which ended on Thursday, Donald Trump announced the US was pulling out of northern Syria and no longer supporting Kurdish forces, leading to an invasion by Turkey.

Why was he charged?

Permission to charge James came from the attorney general, as is required in cases of this kind.

In a pre-trial ruling, the judge alluded to the ultimately political nature of what is classed as terrorism.

Mr Justice Edis said selecting who in foreign conflicts should be charged often involves "political decisions" in that a choice can be made to prosecute opponents and not allies.

While allowing the case to proceed to trial, the judge said he was "uneasy about the prosecution of a man who is able to say that at least some of the acts of terrorism for which [he] was preparing or trained were carried out with the support of the RAF".

Image copyright Facebook Image caption James denies terrorism offences

Half-way through the first trial, the judge directed that James should be acquitted of the charge alleging he prepared for terrorism by taking the steps he did to travel to the region.

On that count, prosecutors were not seeking a conviction if he had been solely preparing to fight IS - since they did not regard that as terrorism - and the judge said there was "no evidence" of any other intention.

The prosecution case was that James had joined a wider struggle than the battle against IS - namely advancing the "political and ideological cause" of the Kurdish people - which placed it within the legal definition of terrorism in UK law, as set out in the Terrorism Act 2000.

But there has been no explanation about why James was put on trial when other Britons who fought with Kurdish forces have not been.

A Whitehall source said fewer than 30 Britons joined Kurdish forces in the battle against IS, but two sources who spent time in the region put the number between 50 and 100. Eight were killed during the fighting.

It is understood that, of the more than 900 people from the UK who joined jihadist groups in Syria, around 450 have since returned, with around 40 being charged with criminal offences, although fewer than half with terrorism offences.

During preliminary hearings, the prosecution declined to say what set James apart from other YPG fighters.

This led the judge to say "no explanation for the apparent difference in the treatment of the defendant as against those other cases has been offered", adding: "I do not think that I have been assisted by the Crown as much as I might have been."

Image copyright Facebook Image caption James spent time at a Syrian YPG training facility

A Briton who fought with the YPG and met James in Syria - known by the pseudonym Macer Gifford - is critical of the decision to prosecute when so many former IS recruits have not been charged.

He told the BBC: "There's a big difference between those who joined the YPG and those who joined the Islamic State," adding those who fought against IS were motivated by compassion for the Syrian people.

Last year, the Crown offered no evidence against the only man who had faced similar charges to James.

Jim Matthews told the BBC there has still been no explanation about why he was prosecuted or why the charges were then dropped.

The former solider, who has written a book called Fighting Monsters about his time in Syria, said that "in the absence of an official explanation it's hard for theories not to abound" and that one theory is "that these charges are being brought as a kind of gesture of support for the Turkish state, with whom we do a lot of business".

He said Western countries "always had this juggling act of wanting to stay friends with Turkey" while combating IS alongside Kurdish forces, which Turkey regards as enemies.

"It's quite an absurd and dirty political dynamic, which - when that filters down to little minnows like me, who really aren't particularly significant or important at all - it produces odd results".

In response to questions from the BBC, a spokesman for the Attorney General's Office denied the prosecutions were politically motivated.

"The CPS is operationally independent and makes its decisions to prosecute independently of government," they said.

They added: "We do not comment on discussions between UK government and its international partners but can confirm that the attorney general has not discussed these cases with the Turkish government."

Image copyright PA Image caption Jim Matthews was accused of attending training camps runs by the YPG

Jurors in James's first trial could not reach verdicts over the training camp charges.

The defendant was convicted by a second jury on Thursday of the PKK camp charge, but cleared of the charge relating to the YPG one.

The training camp charges faced by James - referred to by the defence as "technical" - did not need to show that James trained at either location, but rather that he was present as weapons training occurred while knowing there was a terrorist connection.

After thanking jurors, Mr Justice Edis said "I regard this as a highly unusual terrorist case" and that the verdicts showed the defendant's actions were "not intended to promote any acts of terrorism by him".

Before delivering their verdicts, jurors sent the judge a note - which was not read to the court - apparently expressing something about their thoughts on the case.

The judge told them: "From your note you have a certain degree of sympathy with Mr James's motives."