Puerto Rico has finally and officially filed for protection from its creditors in what amounts to the biggest municipal bankruptcy in U.S. history.

Now comes the real reckoning. After years of wrangling in Washington, San Juan and on Wall Street -- a fight that has pitted hedge funds against some of the poorest U.S. citizens -- a federal judge may at last help decide who gets paid, and how much.

For both sides, the showdown will mean pain, as well as opportunity. Bondholders are certain to take a hit, with the commonwealth saying it can’t pay in full. Puerto Rico, meantime, will find no easy fix for an economic crisis that has driven many thousands of its citizens to the U.S. mainland during a decade-long recession and years of borrowing to cover budget gaps.

“An orderly process for working out Puerto Rico’s debt trouble provides the best hope for Puerto Rico and also the best chance for most creditors to emerge better off,” Brad Setser, senior fellow at The Council on Foreign Relations, said in a telephone interview. “But clearly there’s going to be fights between different groups of creditors.”

The commonwealth is asking a federal court to force creditors to take losses on about $74 billion of debt. The process, called Title III, was created by a U.S. law enacted last year to help Puerto Rico emerge from its economic malaise. Thousands of islanders marched in San Juan’s financial district on May 1, protesting against anticipated spending cuts.

The move, announced by Governor Ricardo Rossello and then followed by a filing in U.S. court in San Juan, came after he and his predecessor both failed to persuade the island’s major creditors to accept less than they’re owed and the government faced an onslaught of new lawsuits stemming from a series of defaults. The governor’s fiscal plan covers less than a quarter of the debt payments due over the next decade.

Hedge funds, including Aurelius Capital Management, Monarch Alternative Capital and Whitebox Advisors, hold about a third of the island’s debt.

The prices of Puerto Rico’s major bonds were little changed after the announcement. General obligations due in 2035, among the most actively, traded for an average of 65.6 cents on the dollar Wednesday, up from 64.7 cents Tuesday, according to data compiled by Bloomberg.