Portland City Hall had the right to use money from sewer bills toward cleaning up the polluted Portland Harbor, a Multnomah County Circuit judge ruled Thursday.

It's a significant win for the city—and for Commissioner Nick Fish, who oversees the city's utilities—in a five-year-long court battle that centered on who would be responsible for cleaning up the Willamette River.

Judge Stephen Bushong ruled that city was justified in charging ratepayers roughly $50 million of the nearly $60 million so far spent on preparations to clean Portland Harbor, a federal Superfund site.

Utility ratepayers sued the city in 2011, demanding that money back, along with city funds used to give waivers to land developers, and pay for parks and public art.

The decision comes a day before the U.S. Environmental Protection Agency is expected to issue its final plan for cleanup of the harbor, which is expected to cost between $750 million and $1.5 billion for all polluters.

The city's responsibilities for that cleanup will be determined by that decision, but today's ruling shows that utility ratepayers will remain on the hook.

"The [city] charter authorized the city to spend sewer ratepayer funds in addressing the city's potential … liability for the Portland Harbor Superfund, subject to an appropriate reallocation after EPA issues its Record of Decision," writes Bushong.

The judge also found the City Council could waive system development charges —the fees paid by developers that cover infrastructure costs for new projects. That's another key win. But spending utility funds for parks projects was not justified, Bushong found.

Fish and John DiLorenzo, the lawyer for the ratepayers who sued the city, did not immediately respond to requests for comment.

UPDATE, 1:03 pm: Mayor Ted Wheeler issued a statement celebrating the ruling.

"Commissioner Fish and I share a vision for our utility bureaus that focuses on the responsible use of public resources," Wheeler said. "I am pleased that the Court agrees that Council has acted appropriately in its use of ratepayer funds."

UPDATE, 2:18 pm: The city estimates today's ruling and previous ones in the suit will require the city's general fund to pay back the utility bureaus a maximum of $16.2 million, according to Deputy City Attorney Karen Moynahan.

DiLorenzo says that the judge's decisions contain good news for water and sewer ratepayers, even though he won on a fraction of the hundreds of millions he had sought.

"Despite the city's attempt to justify its actions, the bottom line is that the court has made clear that approximately $15 million of the city's non-Superfund expenditures from water and sewer funds were not authorized by the charter and will have to be returned to those funds," says DiLorenzo.

"The court has also made clear that the final Superfund expenses must be allocated among all city bureaus, not just the ratepayers.  Time will prove that portion of the decision as great victory for the ratepayers."

Neither the city nor DiLorenzo has decided whether to appeal Bushong's ruling.