Two ethnic Roma (Gypsy) men have won a discrimination case against Hungary at the European Court of Human Rights over their education at a remedial school.
Education in a school for the mentally disabled meant the pair were isolated from mainstream society - a bar to their integration, the judges found.
The Strasbourg court said their schooling amounted to discrimination.
For years many Roma children have been wrongly placed in remedial schools in Hungary and some of its neighbours.
Many Roma communities in Hungary and the neighbouring Czech Republic, Slovakia, Romania and Serbia are blighted by poverty and a high degree of social segregation.
Istvan Horvath and Andras Kiss, from the town of Nyiregyhaza, were born in 1994 and 1992, respectively.
Ruling on their case, the court said the Hungarian school system had failed to provide the necessary safeguards for a disadvantaged minority.
The judgment said Hungarian courts had also acknowledged deficiencies in the way mental abilities were tested.
Hungary was ordered to pay the pair's legal costs of 4,500 euros (£3,848; $6,065). The applicants did not request damages from Hungary on grounds of discrimination.
The BBC's Nick Thorpe in Budapest says the conservative Fidesz government is putting money into teaching Roma culture and history - though some NGOs argue that integrating Roma is more important than building their cultural identity, which can be divisive.
Fidesz argues that it has developed a Roma strategy, aimed at improving Roma rights - something that the EU has long been urging.
Fidesz says Roma-majority schools in some villages are a fact of life, whereas the previous Socialist-led government favoured bussing Roma children to schools where they would have to mix with ethnic Magyars, our correspondent reports.
Hungary's Minister for Human Resources, Zoltan Balog, has said the country "cannot prosper without its Roma population - if the Roma lose, we lose too".
He said the "negative trend" of the majority against the Roma must be changed, at the same time as Roma themselves must shed their "victim mentality". Most Roma are unemployed and poor, he pointed out.
A Council of Europe report in 2009 criticised the over-representation of Roma children in Hungarian remedial schools, while acknowledging that Hungary had made efforts to address the problem.
The report said "the vast majority of children assessed as having a 'mild disability' could, in the view of many NGOs, be integrated relatively easily in the ordinary school system: many children are misdiagnosed due to a failure to take due account of cultural differences or of the impact of socio-economic disadvantage on the child's development".