Joshua Boyle, the former hostage who spent five years held by militants in Afghanistan with his family, has been cleared of all charges in a closely watched sexual assault trial.

Boyle, 36, faced 19 charges, including criminal harassment, uttering threats, unlawful confinement and administering a noxious substance after his estranged wife, Caitlan Coleman, accused him of abusing her after the family were rescued and returned to Canada.

But on Thursday, the Ontario superior court justice Peter Doody said there was not enough evidence to back up Coleman’s testimony.

As he dismissed the charges, Doody cast doubt on much of Boyle’s evidence, but also described Coleman’s testimony as “inconsistent” and called into question her credibility and memory.

“I do not believe her, just as I do not believe Mr Boyle,” said Doody, arguing that the prosecution failed to present a case that was beyond a reasonable doubt.

Boyle and Coleman were already the subject of intense media scrutiny following their dramatic rescue, and Coleman’s subsequent allegations ensured that the case became one of the most high-profile recent trials in Canada.

But Thursdays’ verdict highlighted the immense challenges in adjudicating allegations of sexual assault within the justice system, said lawyers in that field.

Boyle, who attended each day of the trial and took extensive notes throughout the process, was in court with his parents.

“This is an incredible relief to him,” Boyle’s lawyer, Lawrence Greenspon, told reporters outside the court.

Coleman, who lives in the US with her family, travelled to Ottawa to testify in March and April but was not present for the verdict.

“I’ve had a chance to speak with Ms Coleman. She’s devastated by the verdict,” said Ian Carter, her lawyer. “I think the case is an example of the challenges a complainant faces coming forward with allegations of sexual assault or domestic violence … She needs some time to process what was said today and try and move on with her life.”

In 2012, then newlyweds Boyle and Coleman travelled to Afghanistan, where they were kidnapped by a Taliban-linked group shortly after arriving in the restive country.

The couple spent five years as captives of the Haqqani network, during which time Coleman gave birth to three children. They were eventually freed by Pakistani soldiers in October 2017, and returned to Canada.

In late December, Boyle was arrested in Ottawa and charged with 19 offenses – including sexual assault, forcible confinement and uttering a death threat – all of which were alleged to have taken place after the family had arrived in the city.

During the trial, which began in March, Coleman testified that during their captivity, Boyle became physically abusive, choking, punching and slapping, as well as threatening to kill her in front of their children. She also told the court how she fled the couple’s Ottawa apartment in fear for her life, wearing only socks on her feet.

Boyle admitted he had struck Coleman several times, but said he had done so because she frequently asked to be spanked.

Toronto-based lawyer Angela Chaisson, who specializes in sexual assault cases, says complainants often have a difficult time achieving justice in the courts.

She pointed to the case of Jian Ghomeshi, the disgraced Canadian radio host who faced accusations of sexual assault from numerous women – but was acquitted in a controversial 2016 verdict.

“The criminal justice system is in my opinion, a fundamentally flawed way of dealing with sexual assault and domestic violence claims,” she said.

In his ruling, Doody acknowledged the toll their kidnapping ordeal had taken on both Boyle and Coleman, saying he had made an effort to disregard their demeanour in the courtroom.

With much of the verdict centred on credibility, Doody took issue with evidence submitted by the crown, including a list of “rules” which Coleman testified Boyle had drawn up to control her behaviour, diet, exercise and even frequency of sex.

When asked by government lawyers if he wrote the document, Boyle told the court he could not recall writing it, nor could he identify his own writing.

Doody said Boyle’s testimony was not credible, but – given contradictions in Coleman’s testimony regarding the list, Doody concluded the document was only circumstantial evidence.

Doody also expressed concern over Coleman’s reliability as a witness. She was diagnosed with PTSD following her time as a hostage and testified that she suffered from blackouts and “fits” of anxiety.

The judge cautioned that mental health issues do not make a witness unreliable, but nonetheless flagged her “memory issues”, saying they “raise concerns about her ability to accurately recall the events at issue … and whether the events described took place”.

The trial was initially expected to only last weeks, but was repeatedly delayed by procedural questions, including a clash over Coleman’s decision to grant media interviews during the trial, despite Doody’s request not to speak publicly about the case.

The various reasons Coleman gave for giving the interviews lacked consistency, said Doody.

Given that neither side could provide a compelling case, a legal standard of reasonable doubt meant he was obliged to dismiss the charges, he said.

Chaisson said she feared the verdict could have a “chilling effect” on women who are victims of domestic abuse.

“All the high-profile cases that we see are acquittals and that’s not a coincidence,” she said. “That should give us pause, as justice system participants and society at large, and ask us why this is.”

Government lawyers did not make a statement to media following the verdict and have not yet indicated if they will appeal.

“This was really, in large part, a ‘he said, she said’ - there was very, very little confirmatory evidence,” Boyle’s lawyer, Greenspon told Reuters: “Ultimately, [the judge] didn’t believe Caitlan and he had many doubts about Josh’s testimony.”