The Gurkhas say they have suffered "unlawful discrimination"
Ex-Gurkhas who claim they have been racially discriminated against by the UK government have won the right to stage a High Court challenge.
More than 2,000 Gurkhas who retired before 1 July 1997 have been refused permission to settle in Britain.
The men, who say the policy is unfair, were given permission to apply for judicial review by Mr Justice Sullivan.
Lib Dem leader Nick Clegg has written to the prime minister urging him to grant citizenship to the veterans.
The Gurkhas' legal team said that foreign soldiers would normally be eligible to settle in the UK after completing four years' service anywhere in the world.
But Gurkhas who retired before the British Army moved its main base for the regiment from Hong Kong to the UK in July 1997 "continue to be denied the opportunity to obtain settlement on the same basis as foreign soldiers discharged in the same period", their lawyers argued.
This amounted to "unlawful discrimination", they said, adding some veterans have died waiting for immigration appeals while others are seriously ill.
The judge told a courtroom packed with Gurkhas and their families that "an authoritative decision of this court as to whether or not the policy is unlawful" will be made by the end of September 2008.
A hearing will be held over two days from 16 September, with submissions on behalf of the Gurkhas and the Home Department.
Test case appeals over the refusals, which were due to be heard by the Asylum and Immigration Tribunal (AIT) on 21 July, will be delayed pending the outcome.
The judge added: "Once it has been decided whether the policy is lawful it will be much easier to decide each individual case."
Meanwhile, Mr Clegg wrote to Prime Minister Gordon Brown demanding he end the government's legal challenges that prevent the release of 50 files relating to its policy on Gurkha soldiers.
"It is yet another gross insult to the Gurkhas that despite their bravery, unstinting service and commitment to the United Kingdom, they have been wilfully frustrated in their attempts to put their case for leave to remain in the United Kingdom," he wrote.
"I urge you to halt this expensive legal charade and do what is right by the Gurkhas, and grant them all, regardless of retirement date, the British citizenship they deserve."
The Brigade of Gurkhas is based at Shorncliffe, near Folkestone, Kent, although one infantry battalion has its barracks in Brunei.
The brigade was stationed in Hong Kong until the former British colony was given back to China in 1997.