A conservative South Carolina diocese that left The Episcopal Church five years ago has been involved in a complicated dispute over its name, leadership, and land ever since.

Today, the Palmetto State’s supreme court decided that the Diocese of South Carolina—which contains about 50 churches and 20,000 parishioners and is now part of the Anglican Church in North America (ACNA)—does not get to keep about $500 million worth of historic church properties that it claimed in the split.

The ruling declares that 29 local parishes cannot take their properties with them and must return them to the Episcopal Church. However, the breakaway diocese can continue to use its name, seal, and symbols.

A lower court decision in 2015 granted the conservative Anglicans “all their property, including churches, symbols, and other assets,” worth half a billion dollars. That same year, the breakaway diocese rejected an Episcopal attempt to settle the dispute by basically letting the conservatives keep their physical properties in return for giving up their intellectual property. They refused.

Today, the conservative churches received almost the opposite outcome.

The complicated court reversal, which includes opinions from all five justices, hinged on the Dennis Canon, an Episcopal church law granting ownership of parish property to the local diocese and the national church.

Justices ruled that even after the diocese moved to leave the denomination, only churches that had not “acceded” to the Dennis Canon—just seven in the diocese—had the rights to their property.

The Diocese of South Carolina’s lead counsel, Alan Runyan, called the ruling “inconsistent with South Carolina and long-standing United States Supreme Court precedent involving church property disputes.”

The court ruled 3-2 in favor of the Episcopal Church’s property claims. Meanwhile, a 2-2 decision (one justice abstained) on its intellectual property claims allowed the lower ruling on behalf of the diocese to stand.

The diocese, which dates back to 1785 and is older than the Episcopal Church itself, was the fifth to secede over stances on homosexuality and other scriptural issues. Another breakaway diocese, in Illinois, was granted ownership of its property after a court case in 2011.

Splits within the Episcopal Church and other mainline denominations have caused property lawsuits to surge in recent years; in 2016, they became the top reason churches ended up in court.

Skip Adams, bishop of the Episcopal Church in South Carolina, told parishes that the decision fell generally in the national denomination’s favor. “We are grateful for this decision and for the hard work of the court in rendering it,” he wrote. “We also give thanks to God for the faithfulness, support, and sacrifices of countless Episcopalians within our diocese and throughout the church.”

Members of the Diocese of South Carolina, which is composed of thousands of members in the state’s low country, fear the transition of ownership would ultimately leave historic churches—including Charleston landmarks— to sit empty or be sold. Other conservative commentators worry about the amount of money the Episcopal Church has spent in litigation costs—by some estimates, $40 million in South Carolina alone.

The diocese stated that it will continue to review the “lengthy and complicated ruling.” Separate litigation surrounding its bishop, Mark Lawrence, is ongoing.