New Jersey towns and cities must take into account a 16-year "gap period" when calculating their future affordable housing needs, according to a ruling Wednesday by the state Supreme Court.

The decision could mean towns would be under pressure to aid the construction of tens of thousands of additional affordable homes across the state over the next decade, and is a huge win for housing advocates who have pushed for cheaper housing options.

Attorneys for a group of municipalities argued that it was unfair to retroactively foist affordable housing obligations on cities and towns that had been playing by the rules.

The issue had been nearly a year in the making, and centered around the period from 1999-2015 when state officials were not telling municipalities how much affordable housing they needed to provide space for through zoning.

Two earlier state Supreme Court decisions had required that every municipality in New Jersey zone for its "fair share" of affordable housing. But the agency tasked with doling out those "fair share" obligations — the Council on Affordable Housing — failed to act from 1999 to 2015.

Many municipalities continued to build affordable housing, while others cut back on construction as they awaited guidance from the state.

Municipalities calculating their "fair share" obligations for 2015-2025 must consider the two categories required under the law: current substandard housing and the expected demand for affordable housing over the next decade.

The new ruling means that cities and towns now will also have to consider low- and middle-income households that arose during the "gap period" that still need affordable housing.  So if someone in town was in need of affordable housing during that period, and still is in need now, they would be counted toward the town's obligation.

Municipalities must address "the affordable housing need of presently existing New Jersey low- and moderate-income households, which formed during the gap period and are entitled to their delayed opportunity to seek affordable housing," wrote Justice Jaynee LaVecchia.

The court's decision was unanimous, however Chief Justice Stuart Rabner did not participate in the case.

The decision also said that municipalities should not zone for households that would have been eligible for housing during the "gap period" but are not any longer, such as people who have since died, people who now earn too much money to qualify for affordable housing, or people who live in current substandard housing and are therefore already taken into account.

The high court's decision modifies a July state appeals court ruling that said that municipalities did not have to consider a "separate and discrete" obligation that arose during the gap period but may have gone unmet due to state government inaction.

In July of last year, in the first such ruling, a Superior Court judge ruled that several Ocean County municipalities had to consider the "gap period" in estimating their future affordable housing obligations.

Since Gov. Chris Christie dissolved the Council on Affordable Housing in 2011, the responsibility for deciding municipalities' affordable housing obligations has fallen to the state's trial courts.

More than 90 cities and towns across the state have reached settlements in the state's trial courts over their affordable housing obligations for the next decade, totaling more than 31,000 units.

A report commissioned by the advocacy group Fair Share Housing Center estimated that municipalities will be obligated to zone for more than 100,000 units of affordable housing from 2015-2025, while another report commissioned by a group of municipalities put that number at 37,700 homes.