Andrew Mountbatten-Windsor has won a High Court battle over the searches of his two homes earlier this year.
Thames Valley Police got approval from an Old Bailey judge for the dramatic swoops on Wood Farm in Sandringham and Royal Lodge in Windsor.
But the disgraced former prince challenged the legality of the searches and today at the High Court it has emerged that he has been successful.
It throws into doubt evidence gathered during the police investigation into Andrew, who was arrested on February 19, his 66th birthday.
He was held for nearly 12 hours before being released on police bail. He has not been charged with any offence.
At a hearing at the Royal Courts of Justice on Thursday, which Andrew did not attend, Mr Justice Hilliard said that 'agreement was reached between the claimant and Thames Valley Police that the search warrants were unlawful'.
But the judge also said that 'the fact that the search warrants were quashed does not bring an investigation to an end or mean that the whole of the investigation was unlawful'.

Andrew Mountbatten-Windsor earlier this year, after police raids on his house involving a search of Royal Lodge that went on for several days

Andrew Mountbatten-Windsor leaving Aylsham Police Station after he was released from custody in February

An aerial view of police visiting Royal Lodge in Windsor, Berkshire, on Friday, February 20
In an extraordinary hearing at the High Court, Mr Justice Hilliard explained why the public had been kept in the dark until now.
He said that because Thames Valley Police had conceded 'shortly' after Andrew launched his bid that the searches had been unlawful, there had been no public hearing.
The former prince's legal challenge centred on documents in his possession falling under the category of 'special procedure' material. As Andrew may have acquired these as part of his 'paid or unpaid' duties, they would have been legally 'privileged'.
The police accepted that it was not possible to say the items they had seized did not fall into this category and that therefore it was not possible for the Old Bailey judge to have properly approved the search warrants.
Mr Justice Hilliard said that had been 'not, however, the end of the matter' because on June 4, police made an application to retain the items they had seized. The police can keep Andrew's belongings if they can show there is some other reason why they should be allowed to retain them.
The judge said: 'There would be little point in handing property back if it could then simply be lawfully seized under some other provision.
'The fact that the search warrants were quashed does not bring the investigation to an end or mean that the whole of the investigation is unlawful.'
The police's Section 59 application to retain the items seized will be heard by Mr Justice Hilliard next year.

Police officers in plain clothes arrived at Wood Farm in February where searches began

A convoy of cars drove close to Wood Farm in Sandringham shortly before it was revealed that Andrew had been arrested on his 66th birthday
The High Court quashed the search warrants on July 22, after being told that the police had conceded the point.
The judge said: 'The basic facts are straightforward. A significant error was made in the application for and grant of the search warrants. Acknowledging that error is important.
'When warrants are quashed, Parliament has provided a procedure whereby the police may be able to retain the material if there is a legitimate basis for doing so. I will decide that question in due course.'
In a remark about when the police would complete their investigation, Mr Justice Hilliard said: 'I suspect that is quite a way off.'
The public will be given more details about Andrew's legal challenge later this month.
The judge said documents in the case would be made public but he gave the parties in the case 14 days to make representations about whether redactions were necessary – for example, to black out the names of police officers.
It emerged that it was only when a Daily Mail journalist got wind of the case and asked for access to the legal documents last week that the judge decided to arrange a hearing to determine if the police's wishes to keep them secret should be held.
Since then, he said, police had dropped their application, and the case documents will be made public.
King Charles previously stripped his brother of titles after weeks of pressure to act over Andrew's relationship with late financier and convicted paedophile Jeffrey Epstein.
That came after the former prince said he would no longer Epstein victim Virginia Roberts Giuffre in her posthumous memoir.
Ms Giuffre, who died by suicide in April, alleged she was forced to have sex three times with Andrew, which he vehemently denies, including when she was 17 and also during an orgy, after she was trafficked by Epstein.
Andrew paid millions to settle a civil sexual assault case with her in 2022, despite insisting he had never met her.
A Thames Valley Police spokesman said this afternoon: 'On 22 July, the High Court quashed search warrants granted on 18 February 2026 for two properties in Norfolk and Berkshire that were searched as part of Thames Valley Police's ongoing investigation into misconduct in public office by a man in his 60s from Norfolk.
'The agreement that led to the quashing of the warrants relates specifically to a decision made by the court regarding the legal basis for these and is not a judgement on our ongoing investigation.
'We ensured the court was presented with all the necessary information and paperwork to inform their decision, following the correct legal processes throughout.'

Onlookers said eight people were in plain clothes 'but appeared to be police officers'

Police officers at the gates of Andrew's former home in Berkshire, Royal Lodge, in Windsor
The force said it accepted 'the position that the initial court's decision to issue warrants under the specific piece of legislation used was incorrect and therefore these must be legally quashed'.
The spokesman added: 'Legal proceedings are currently ongoing to decide how material seized during the searches will be managed and whether we can lawfully retain it in support of our ongoing investigation.
'Our investigation into alleged misconduct in public office by a man in his 60s from Norfolk remains ongoing, and we continue to pursue all reasonable lines of enquiry to effectively and fairly progress this investigation.
'Due to these ongoing legal proceedings, we cannot currently provide further comment.'
Blame for the fiasco was laid at the door of the Old Bailey, with Thames Valley Police saying it was a 'judicial' mistake.
Alan Payne King's Counsel, for Thames Valley Police, told the court: 'The judge made an error in granting the warrants.'
Police sources insisted they had taken 'every reasonable step at the time of the application' to ensure the Old Bailey judge had all the necessary information and paperwork.
They blamed the unnamed judge for issuing the warrants under Section 8 of the Police and Criminal Evidence Act, rather than under Section 9.