The Gurkhas gave three cheers for British actress Joanna Lumley, who supported their campaign because her father was a member of the regiment.
'A great wrong'
Lumley said: "This day is more important than I can tell you.
"It gives our country the chance to right a great wrong and to wipe out a national shame."
During the hearing, Edward Fitzgerald, the Gurkhas' barrister, said a decision to bar them because they were based in Hong Kong until the territory was returned to China in 1997, was unfair.
He also rejected government claims that they did not have close links with Britain.
High court judge Mr Justice Blake ruled that instructions given by Britain's interior office to immigration officials were unlawful and must be changed.
Renowned for bravery
After the ruling, Jacqui Smith, Britain's interior minister, said the rules would be rewritten.
Smith said: "In light of the court's ruling we will revise and publish new guidance. We will honour our commitment to the Gurkhas by reviewing all cases by the end of the year."
Britain's ministry of defence made no comment on the ruling.
About 2,000 Gurkhas are affected by the current rules.
All other foreign soldiers in the British Army are allowed to settle in Britain after four years' service anywhere in the world.
Gurkhas were first recruited by colonial rulers in India in the 19th century as a "martial race" known for their bravery.
They have fought for Britain since 1815, most recently in Iraq, Afghanistan and the former Yugoslavia.