A judge Wednesday ordered North Carolina to put an additional $1.7 billion into public education over the next two years. The money would go into a fund to make sure students in North Carolina are getting a sound basic education.

The order from Wake County Superior Court Judge David Lee is the latest twist in a legal saga spanning more than 25 years. At its core, the dispute is about giving school districts enough money to provide students in public schools a good education.

“The people of North Carolina have a constitutional right to an opportunity to a sound basic education,” Lee said in his order. “It is the duty of the State to guard and maintain that right.”

Lee’s order gives the North Carolina General Assembly, which creates the state budget, 30 days to fully fund the education plan. But Republican legislative leaders said the order was politically motivated and could potentially sue to stop it.

How did we get here?

In 1995, students and school districts in some of North Carolina’s poorest counties, including Hoke, Halifax and Vance, sued the state over education funding. Kathleen Leandro, guardian ad litem for Robert Leandro, was the lead plaintiff in the case.

“The State of North Carolina has failed to provide students with the education they are owed under our constitution,” said Every Child NC, an advocacy group. “That failure has disproportionately been born by students of color, students from families with low incomes, English learners, students with disabilities, and rural students.”

In 2004, the North Carolina Supreme Court sided with the plaintiffs and ordered the state to increase education funding. The court found that many students did not receive a “sound basic education,” especially in high-poverty schools.

The case has a long, complicated legal history.

Over the last 17 years, the court has reviewed the state’s progress in improving education. A 2015 court order found, “In way too many school districts across this state, thousands of children in public schools have failed to obtain and are not now obtaining a sound basic education as defined and required by the Leandro decision.”

The judge said that for many students, things have actually gotten worse since that 2004 Supreme Court ruling.

The plan says the state has to provide “competent certified teachers, well-trained competent principals” and more resources to make sure all students get an equal opportunity at a sound basic education.

What does the judge’s ruling say?

The judge faults the North Carolina General Assembly for not giving enough funding to school districts.

“Because the State has failed for more than seventeen years to remedy the constitutional violation as the Supreme Court ordered,” Lee writes, the court will have to step in to increase funding.

The plaintiff in the case, the school systems and now-former students, proposed an order to the judge that would send about $1.7 billions to public education. The State Board of Education, one of the defendants, proposed small revisions to the plan, and the Attorney General’s Office did not suggest any alternatives.

The judge found that the state has more than enough money in reserves to fund the plan, including $8 billion in reserves and $5 billion in forecasted revenue.

If the General Assembly doesn’t fund the plan in its new budget, the court ordered the state budget office and the treasurer to transfer about $1.7 billion to education, mostly to the Department of Public Instruction.

How does this work with the General Assembly’s budget?

The court’s order comes as Republican leaders in the General Assembly prepare to release their budget as soon as next week. But it doesn’t appear likely that they will include the additional funding.

“This case has devolved into an attempt by politically allied lawyers and the Governor to enact the Governor’s preferred budget plan via court order, cutting out the legislature from its proper and constitutional role,” Senate Leader Phil Berger and House Speaker Tim Moore said in a joint statement Wednesday.

“If Judge Lee’s orders are followed, the legislature’s core duty is usurped by unelected county-level trial judge and an out-of-state consultancy funded by the Governor and his political allies,” they said.

Gov. Roy Cooper, a Democrat who has veto power over the budget, applauded the ruling Wednesday.

“This is not a new or confusing concept: a bipartisan N.C. Supreme Court twice has ruled that the state is failing to guarantee the right to a sound, basic public education,” he said in a statement. “Legislators can’t simply erase this right because they don’t like it.”

What happens next?

The order could be setting up a legal showdown between North Carolina’s judicial branch and the state’s legislative branch.

Legislative leaders could sue to stop the order. The General Assembly is in charge of the state’s pursestrings.

Lee addresses those constitutional questions in his order, arguing that you can’t violate the constitution by trying to fix a constitutional violation. “The appropriations clause cannot be read to override the people’s right to a sound basic education,” the judge said.

With the order from the judiciary branch though, it’s not the legislature’s job to actually disperse the money. That falls under the executive branch with the governor, state treasurer and controller.

The judge gave the other branches of government 30 days to figure out if they can fund education themselves through the budget process. It remains to be seen what will happen between now and December 10.