Municipal officials who have been fuming over the unfair way in which the state is attempting to seize affordable-housing money now have a chance to fight back.

The Appellate Division of Superior Court issued a ruling on June 6 that sets up a process for the state to take the money but also gives municipalities a chance to justify why they should be able to keep the funds. The court also gave municipalities the right to appeal decisions by the Council on Affordable Housing.

Gov. Chris Christie called the ruling a victory for his plan to use the money - about $142 million - to help balance the upcoming budget. But the timetable the judges set up would mean no firm decision could be made before the July 1 budget deadline.

That doesn't mean Christie won't still try to take the funds. The law allows the state to confiscate affordable-housing funds that remain unspent four years after they were collected from developers.

But it does mean that municipal officials - who have argued that the state has acted in bad faith by failing to issue the guidelines necessary to spend the housing funds or to approve plans in a timely manner - have an opportunity to try to keep the money.

The court said COAH must issue a new letter to municipalities explaining their rights. Towns would have 30 days to respond and to defend their spending plans. The COAH board would have to vote before any money could be seized by the state. Municipalities would be able to appeal the board's decision to the court.

In their order, judges were critical of COAH's failure to set up a clear procedure for spending the housing funds. And that's been the rub all along. After all, how could COAH approve spending plans when it hadn't even met in two years?

First Christie disbanded COAH in 2011. The Appellate Division stopped the Department of Community Affairs from seizing unspent affordable-housing funds in 2012, saying only COAH had the authority to do that.

So Christie reconstituted COAH. The group met in May, for the first time since 2011, and rubber-stamped the governor's plan.

Housing activists were rightly outraged, while municipal officials felt as though the game had been rigged against them and the state was shifting the burden of providing affordable housing onto local taxpayers.

These funds were never intended to become general revenue for the state. They are supposed to help finance affordable-housing projects.

Now, if towns act quickly, that can still happen.