A judge upended an agreement between the University of North Carolina and a pro-Confederate group Wednesday, reopening the polarizing question of what to do with the statue known as “Silent Sam.”

It was the latest twist in a wrenching fight over the statue of a Civil War soldier that stood for more than a century at the heart of the UNC-Chapel Hill campus. The monument was pulled down in 2018 by people who saw it as an enduring symbol of racism.

In November, state university officials announced a legal settlement they said would rid the university system of the statue without violating a state law protecting historical monuments. But many on campus and beyond were angered that the deal, never debated in public before it became final, turned the statue over to a pro-Confederate group and required a $2.5 million fund for its care.

On Wednesday, a judge overturned that settlement — unexpected and welcome news for many on the state’s flagship campus.

“There will be a lot of celebration today,” said Eric L. Muller, a law professor. That included one colleague in tears of joy over the unexpected outcome. “And tomorrow people will wake up and realize we still have this damn statue and we don’t know what to do with it,” Muller said.

An attorney for the pro-Confederate group said Wednesday his client is disappointed and disagrees with the order but will comply.

The statue will “be returned to UNC,” said C. Boyd Sturges III, attorney for the North Carolina Division of the Sons of Confederate Veterans. But he said he did not yet know how it would be returned.

“It’s not like it’s in the boot of my car,” Sturges said. “The thing is 16 tons. It’s solid bronze.”

The question of what to do with Silent Sam after it was toppled spurred conflict, with many on campus calling it a hateful symbol of white supremacy and demanding it be banished from the public university. But many state leaders insisted it be restored, in keeping with North Carolina law.

In November, UNC officials announced that the Sons of Confederate Veterans group had sued the statewide system and its board of governors and that a settlement had been reached: UNC gave the group rights to the monument, with the requirement that the statue not be kept in any county with a UNC institution. The settlement also paid $2.5 million for an independent trust for preservation of the statue.

For months, critics have been asking questions about the settlement, such as why the chairman of the board of governors signed it days before the lawsuit was even filed. They asked why the United Daughters of the Confederacy’s North Carolina Division, which had originally proposed that the statue be erected on campus, signed rights to the statue over to the state division of the Sons of Confederate Veterans just days before the lawsuit was filed. They questioned why university officials settled a lawsuit brought by a group that, they argued, did not have legal rights in the case.

A national civil rights group representing several students and a faculty member asked the court to overturn the settlement, and the judge agreed to consider the issue of whether the local chapter of the Sons of Confederate Veterans had standing to bring a lawsuit.

A group of nearly 90 UNC alumni supporters also filed a brief arguing that UNC owned the statue, not the pro-Confederate groups. They cited records compiled by a UNC historian who retired in August that concluded the United Daughters of the Confederacy contributed about a third of the $7,500 cost of the statue. Alumni raised the other two-thirds. The university contracted with the sculptor and paid for the statue, which was delivered to UNC and erected in 1913. The United Daughters of the Confederacy could not have made a gift of something it never owned, they argued.

On Wednesday, Superior Court Judge Allen Baddour, who approved the initial settlement, vacated it and dismissed the lawsuit, ruling that the plaintiff did not have standing to bring the lawsuit.

R. Kevin Stone, commander of the North Carolina Division of the Sons of Confederate Veterans, did not immediately respond to a request for comment Wednesday.

The decision prompted further questions. Baddour asked in the hearing, broadcast on WRAL, whether money had been paid out from the trust. Sturges said about $50,000 had been spent to pay his fees.

Elizabeth Haddix, an attorney with the Lawyers’ Committee for Civil Rights Under Law, said by phone later that the trust had been ruled void along with the settlement that created it. “It’s not appropriate for public money to be spent for attorneys’ fees for the Sons of Confederate Veterans,” she said. “Somebody needs to pay somebody back.”

Baddour asked for an accounting of the funds. He also asked about the statue.

Ripley Rand, a private lawyer representing the UNC System and the UNC Board of Governors in this matter, later said in a written statement that it was not the result they had hoped for but that they respect the court’s ruling.

“The Board of Governors knew from the very beginning that this was a difficult but needed solution to meet all their goals to protect public safety of the University community, restore normality to campus, and be compliant with the Monument Law,” Rand said. “The Board of Governors will move forward with these three goals at the forefront and will go back to work to find a lasting and lawful solution to the dispute over the monument.”

A spokeswoman for UNC-Chapel Hill deferred questions to the state system.

“The hot potato is now back in UNC’s hands,” Muller said. “They thought they had found a clever way of tossing it out of their hands to the Sons of Confederate Veterans.”

Walter Jackson, chairman of the UNC Black Pioneers group that represents graduates who helped integrate the school, said he was delighted by the judge’s decision.

The statue should never come back to campus, he said. “It presents a clear and present danger to the whole university community,” Jackson said. “If there is a way to destroy it or put it in storage or something of that nature, I think that would be a good thing.”