A supreme court in Bosnia-Herzegovina has ruled that the segregation of schoolchildren "based on ethnic background" is illegal, ordering the country's racially divided schools to finally end the practice almost twenty years after the end of the Bosnian War.

The ruling is a slap-in-the-face to nationalist politicians in Bosnia's southern region, the autonomous Federation of Bosnia and Herzegovina, who have long resisted calls for integration. In 2007, one Bosnian education minister, Greta Kuna, scoffed at the notion that Croat and Muslim children could be taught in shared classrooms: "You can't mix apples and pears. Apples with apples and pears with pears."

The court's decision applies to the largely Croat and Bosniak (Muslim) populated Federation, in which around fifty public schools use a "two schools under one roof" model. Under this system, Croat and Bosniak students study in communal facilities — but in separate classrooms, with separate teachers — who drink coffee in separate break rooms — and using separate textbooks that teach distinct and ethnically-tinged versions of history. In some cases, students enter the building via separate entrances and play on separate sections of the playground.

"It's not really that someone is prohibiting (children) from being friends," Aleksandra Krstovic, a program adviser for education at the OSCE Mission to Bosnia and Herzegovina, told VICE News. "But opportunities to spend time together are very limited… The practice is that they stay with their own groups."

The effects have been reflected in successive opinion polls. A 2011 Council of Europe report noted that one in six Bosnian children do not want to study in mixed classrooms. One in eight Bosnian students avoid interactions with other ethnic groups. In 2009, a UNICEF report found that a majority of young Bosnians believed that "being attached to one's people is one of the most delightful feelings one can have." Though today's students are too young to have witnessed the Bosnian war, they have inherited its scars.

In a statement, Federation Education and Science Minister Damir Masic said he hoped the new supreme court ruling would allow "children to live with one another and spend time together."

The case began in 2012, when the human rights NGO Vasa Prava initiated a case in the southern city of Mostar. That year, a municipal court ruled that Croat and Bosniak children should no longer be segregated. The verdict was overturned by a cantonal court, but then upheld by the Federation's supreme court late last month, on October 29.

Though the ruling only applies to the Federation as the sole region over which the court has jurisdiction, school segregation exists in varied forms across the country. For the last two years, some Bosniak parents in the Serb-dominated Republika Srpska (Serb Republic) have boycotted state schools — demanding that their children be taught separately and according to an explicitly Bosniak curriculum. In January, Balkan media reported that a group of Bosniak children was withdrawn from a Sarajevo school and re-assigned to a makeshift single ethnicity facility outside the city.

Indeed, each of Bosnia's three ethnic groups, Serb, Croat and Bosniak, boasts its own distinct curriculum — and parents have the right to choose which program their children follow. Previous efforts to build a common core curriculum have floundered.

History classes, in particular, are fraught with ethnic politicking—even when they address long-ago topics, like who shot Austrian Archduke Franz Ferdinand in 1914. In 2008, the Open Society Foundation published excerpts from a variety of school texts. "Orthodox Christianity is the most important religion," read one Serbian textbook. "Muslims are ethnic group and not religion (sic)," read a Croat text. "All the Serbs did aggression and genocide on Bosnia and Herzegovina," instructed a Bosnian guide.

In 2000, the Council of Europe went so far as to recommend that Bosnian schools stop teaching the history of the Bosnian War. It proposed a fixed-term moratorium until local historians could agree "on a version (or versions) of recent events which everyone accepts." So far, that hasn't happened.

This segregationist state of affairs is, in fact, a relatively new phenomenon. Like much in the country, it began with the dissolution of Yugoslavia in 1991 — which begot the 1992-5 Bosnian War that gave rise to three years of battle between Bosnian Croats (backed by Croatia), Serbs (backed by Serbia) and Bosniaks. War and ethnic cleansing claimed nearly 100,000 lives and displaced over two million people.

The war ended in 1995, when American and European officials brokered a peace deal near Dayton, Ohio. The Dayton Agreement was hailed as a diplomatic success — for it at last got Bosnian factions to stop slaughtering each other.

But as a concession to nationalists, the Dayton Agreement left broad ruling powers in the hands of ethnic parties. This, in turn, gave rise to a tangle of overlapping and competing government offices that have, in the view of some critics, rendered Bosnia ungovernable. The education sector is a victim of this institutional sclerosis. Today, the country has 14 distinct education ministries, each touting different educational standards.

After 1995, displaced Bosnians began returning to their homes. But they were wary of each other — and so began to settle amongst themselves. By some estimates, post-war Bosnia was soon more ethnically segregated than the pre-war state. When parents resisted calls for integrated school districts, the "two schools under one roof" system was born.

Robert Beercroft, former ambassador and OSCE head of mission to Bosnia, told VICE News that 'two schools under one roof' "was meant to be a transitional stage for the reintegration of schools. But of course, it took on a life of its own."

The supreme court decision promises to reverse the tide — at least for the Federation — but implementation will be tricky. The country's governments have vowed to end school segregation before. Federation Education Minister Masic says that it is up to individual districts to enforce the court ruling.

"It will not be easy to convince some Croats and Bosniaks" to end segregation, Daniel Serwer, a former US State Department official and special envoy to Bosnia, told VICE News. "They fear abuse of the schools by the other group." Others doubt that the political will for change exists in still-bullet-riddled Sarajevo, where Bosnia's three presidents (one Serb, one Croat and one Bosniak) reside.

Will it succeed? Sometimes, when asked a political question, a Bosnian will reply with a telling quip: "I am of three minds about that."