Harry, King Charles III's younger son, had brought the action against the government at the High Court in London after the Home Office - the ministry responsible for policing - decided in February 2020 that he would cease to automatically receive personal police security while in Britain.
Harry, the Duke of Sussex, along with other senior royals, had received full publicly-funded security protection provided by the state before he stepped back from his royal duties and moved to California with his American wife Meghan in March 2020.
His lawyers told a hearing in December last year that the decision to take this away subjected him to unlawful, unfair and unjustifiable treatment.
But the government's legal team said the Executive Committee for the Protection of Royalty and Public Figures, known as RAVEC, had not decided Harry should not receive protection, but that he should not have it on the same basis.
The High Court agreed, concluding that there had been no unlawfulness in the decision.
"We are pleased that the court has found in favour of the government's position in this case, and we are carefully considering our next steps. It would be inappropriate to comment further," a Home Office spokesperson said, adding the protective security system was "rigorous and proportionate".
Harry's legal spokesperson said in a statement that he intended to bring an appeal.
"The Duke is not asking for preferential treatment, but for a fair and lawful application of RAVEC's own rules, ensuring that he receives the same consideration as others in accordance with RAVEC's own written policy," they said.
Harry was last in Britain earlier this month when he made a whistle-stop visit to see his father after it was revealed the King had been diagnosed with an unspecified form of cancer.
The 39-year-old, who has become estranged from his family since his move to the United States, has said he hoped Charles' illness could bring the family together.
OTHER LAWSUITS
Whereas the British royals usually adopt the mantra of 'never complain, never explain', Harry has brought a series of high-profile lawsuits with mixed results so far.
He successfully sued Mirror Group Newspapers over claims of phone-hacking and other unlawful activities, and has been given permission to take similar cases against two other major British publishers to trial.
But he also withdrew a libel claim against a newspaper relating to a story it had written about his security protection dispute.
Wednesday's ruling marks his second legal defeat on the issue of his security after the High Court ruled against him in a separate challenge against the government's refusal to let him pay for his own police protection.
Harry has often spoken out about his fears for the safety of his family (he has two young children), and has regularly hit out at press intrusion which he blames for the death of his mother Princess Diana. She was killed when her limousine crashed as it sped away from chasing paparazzi in a Paris tunnel in 1997.
Britain's former counter-terrorism police chief said last year there had been credible threats made against the couple by far-right extremists.
The ruling comes as the government announced an extra £31 million ($NZ64 million) on Wednesday to provide new security provisions for lawmakers and other officials amid growing concerns about their safety.