Detroit will become the largest city in U.S. history to declare bankruptcy after a federal judge ruled Tuesday the city had met the legal criteria to win protection from its creditors.

U.S. Bankruptcy Judge Steven Rhodes delivered the 140-page ruling after four months of legal wrangling between a state-appointed emergency manager and unions worried about the bankruptcy’s impact on pensions. Rhodes presided over a nine-day trial to determine whether the city met the requirements for bankruptcy protection.

“This once proud and prosperous city can’t pay its debts. It’s insolvent. It’s eligible for bankruptcy,” Rhodes said from the bench. “At the same time, it also has an opportunity for a fresh start.”

Detroit, once a city of 1.8 million and the home of the American auto industry, has suffered a long descent into financial crisis. The city was home to just 713,000 people, according to the 2010 Census, a mere shadow of its post-war apex. Huge pension costs and a recession that sent American automakers into their own financial tailspins exacerbated Detroit’s budget gaps.

On July 18, with Detroit facing an estimated $18 billion in debt and liabilities, it became the largest city in American history to file for bankruptcy protection. Almost 40 cents of every dollar the city collected was used to pay down debt, an amount the city said would skyrocket to 65 cents on the dollar without bankruptcy protection, according to the Associated Press. Detroit said it owed money to more than 100,000 creditors.

Under Chapter 9, the city’s emergency manager, Kevyn Orr, will explore ways to pay off some of its debt while restoring some social services, all under court supervision.

Orr will be able to consider pension cuts as part of his final proposal, Rhodes ruled. But Rhodes said he would only allow the cuts if the final reorganization is fair, the Detroit Free Press reported. Unions protested that bankruptcy would threaten the pensions of retirees and current employees.

At a news conference, Orr said selling the city’s art collection was still an option. He said pension cuts would be necessary to emerge from bankruptcy, but that he would work to mitigate the impact.

“We’re trying to be very thoughtful, measured and humane,” Orr said.

An attorney for the American Federation of State, County and Municipal Employees, Sharon Levine, told the Associated Press after the ruling that the union would appeal the decision to the 6th U.S. Circuit Court of Appeals in Cincinnati.

“There’s going to be a lot of pain for a lot of different people. But in the long run, the future will be bright,” outgoing Mayor Dave Bing (D) said at a news conference after the ruling.

Michigan’s constitution doesn’t allow reducing pensions already owed to public workers, except in cases of bankruptcy.

Michigan Gov. Rick Snyder (R) supported Detroit’s move. Snyder appointed Orr to oversee the city during the proceedings.

“Authorizing the emergency manager to seek federal bankruptcy protection was a difficult decision, but it was the last viable option to restore the city and provide Detroit’s 700,000 residents with the public services they need and deserve,” Snyder said in a statement. “We know that Detroit’s comeback is already in motion.”

Correction: An earlier version of this story misspelled Detroit Emergency Manager Kevyn Orr’s name.