A US judge has dismissed criminal charges against former FBI Director James Comey and New York Attorney General Letitia James, ruling that the prosecutor who brought the charges was unlawfully appointed.

Judge Cameron Currie said that Lindsey Halligan, who was handpicked by Trump to bring the charges against two of his political adversaries, was never eligible to assume the post.

Both Comey and James have maintained their innocence and described the prosecutions as political in nature.

In response to the ruling, the White House told the BBC: The facts of the indictments against Comey and James have not changed and this will not be the final word on this matter.

President Donald Trump has repeatedly attacked Comey and James, declaring in one social media post, They're all guilty as hell, and later adding JUSTICE MUST BE SERVED, NOW!!!

In her decision on Monday, Judge Currie wrote that Halligan, a former White House aide who had never prosecuted a case before, was not authorised to present the charges to the grand jury.

All actions flowing from Ms Halligan's defective appointment, including securing and signing Mr Comey's indictment, were unlawful exercises of executive power and are hereby set aside, Currie ruled.

Halligan was named as a replacement for Erik Siebert, an interim US attorney who resigned in September amid the Trump administration's pressure to file charges against both Comey and James.

Judge Currie determined that Halligan's appointment violated the statute governing interim US attorneys. Under that law, the attorney general has 120 days to make an interim appointment - a period that began on 21 January with Siebert's designation, the judge noted.

When that 120-day window closed on 21 May, the attorney general's authority to appoint an interim replacement expired as well, Judge Currie wrote. As a result, Halligan has been unlawfully serving in that role since her 22 September appointment.

The cases were dismissed without prejudice, meaning the justice department could potentially refile the case at a later date.

After the ruling, Comey said he was grateful a prosecution based on malevolence and incompetence had ended, but noted Trump will probably come after me again.

James issued a statement saying she was heartened by today's victory and expressed her commitment to continue fighting for New Yorkers.

Following the ruling, the White House Press Secretary stated they would appeal the dismissal, asserting that Halligan had been legally appointed.