A 31-year-old man, referred to in court only as "Mr A", has succeeded in altering the law and won a 1,000 payment.
He claimed that adding his name to the sex offenders register for life - following two sex attacks carried out when he was in his teens - breached his human rights. The key to his claim was that there was no future appeal or way of getting his name removed from the register, even if he could show he no longer posed a threat to the public.
After the ruling at the Court of Session in Edinburgh, Mr A's solicitor, Tony Kelly, said that the decision was "a complete vindication" of his client's six-year legal battle. Mr A was not in court to hear the decision.
Mr Kelly added: "There are lots of similar cases to come to court."
Figures from earlier this year revealed 3,916 names on the sex offenders register in Scotland. Of that total, 1,631 were on the list indefinitely. Of these, 411 were in prison, six in hospital and 1,214 living in the community.
Now, because of new rules pushed through the Scottish Parliament last month by Justice Secretary Kenny MacAskill, anyone whose name is added to the register has the right to have their status reviewed.
The order lists a number of factors which police chief constables have to consider if they want to keep an offender on the register after 15 years in the case of adults and eight years for young offenders.
The new rules, designed to fit in with the European Convention on Human Rights, were the result of this case, said Mr Kelly.
"This is the end of a long, hard slog," he said. "This case has been going in excess of six years and this is a complete vindication of the position taken by Mr A.
"He has secured a change in the law, he has a judicial declaration of the breach of his human rights and 1,000."
In December 1993, Mr A appeared at the High Court in Airdrie where he admitted two charges of assault with intent to rape, as well as allegations of robbery, theft, and vandalism.
The next month he was sent to a young offenders' institution for four years. He was 14 when the offences were committed, in July and September 1993.
In September 1997 the Sex Offenders Act came into force, which applied to anyone serving a jail sentence for a sex offence.
The requirement to update police when changing address or name applied for life if the sentence was longer than 30 months. Offenders were also subject to regular checks. Police can also demand samples of hair, blood and saliva for DNA tests.
Mr A claimed that the rules were incompatible with his right to private and family life, as guaranteed by the European Convention on Human Rights.
He said giving his address also identified anyone he was living with.Mr A said police had visited him monthly and had spoken to his girlfriend and her family. He said he would never be free to put his past behind him.
Lord President Lord Hamilton, sitting with Lords Reed and Bonomy, had expected to hear two days of legal argument.
But instead, lawyers told them that agreement had been reached - in line with a Supreme Court ruling in a similar English case - and the judges ruled that should be the end of the matter as far as Mr A was concerned.