A group of retired Gurkhas fighting for the right to settle in Britain have won an immigration test case at London's High Court.
They were challenging immigration rules which said that those who retired from the British Army before 1997 did not have an automatic right to stay.
Prominent supporter actress Joanna Lumley, whose father served with the Gurkhas, said it was a "chance to right a great wrong".
The government said it would now review all Gurkhas' cases.
The regiment moved its main base from Hong Kong to Britain in 1997 and the government had argued that Gurkhas discharged before that date were unlikely to have strong residential ties with the UK.
That meant those who wanted to settle in the UK had to apply for British residence and could be refused and deported.
The judgement could affect some 2,000 former Gurkhas who retired before 1997.
Mr Justice Blake said the Gurkhas' long service, conspicuous acts of bravery and loyalty to the Crown all pointed to a "moral debt of honour" and gratitude felt by British people.
He ruled that instructions given by the Home Office to immigration officials were unlawful and needed urgent revision.
Lawyer Martin Howe said: "Today we have seen a tremendous and historic victory for the gallant Gurkha veterans of Nepal. This is a victory that restores honour and dignity to deserving soldiers who faithfully served in Her Majesty's armed forces.
"It is a victory for common sense; a victory for fairness; and a victory for the British sense of what is right."
Gurkhas have been part of the British Army for almost 200 years and are hand picked from a fiercely contested recruitment contest in Nepal to win the right to join.
Home Secretary Jacqui Smith said in a statement that the Home Office would revise its guidance surrounding the 1997 cut-off date.