Rescue legislation aimed at helping Puerto Rico address its mounting fiscal crisis cleared Congress Wednesday, two days before the U.S. territory is set to default on roughly $2 billion in debt payments.

The bill passed by the Senate on a 68-to-30 vote opens a path for an orderly restructuring of the island’s $72 billion in bond debt while creating a new federally appointed fiscal oversight board. It passed the House earlier this month, and President Obama has said he will sign it.

“Obviously, the bill isn’t perfect,” Senate Majority Leader Mitch McConnell (R-Ky.) said Wednesday, before arguing that it “offers Puerto Rico the best chance to return to financial stability and economic growth over the long term so we can help prevent another financial crisis like this in the future.”

The passage of the bill — the Puerto Rico Oversight, Management, and Economic Stability Act, or PROMESA — was in doubt earlier this week, and, had it failed Wednesday, the anticipated missed payments likely would have roiled credit markets and sparked creditor lawsuits. 

The opposition did not fall neatly along party lines. Democrats raised a host of objections to the bill, including over the anti-democratic nature of the oversight board, the relatively arcane restructuring process and a provision that could lower the minimum wage for young workers. Some Republicans, meanwhile, found some provisions unfair to creditors and feared the rescue bill could set a precedent for fiscally troubled states to seek federal intervention.

Two key supporters of the legislation — Treasury Secretary Jack Lew and Puerto Rico Gov. Alejandro García Padilla — lobbied heavily to win over skeptics.

Lew met with Democratic members of the Senate Finance Committee Tuesday after having made dozens of phone calls to members of Congress over the past two weeks.

“For everyone who says you can’t do hard things it’s a reminder than you can do hard things,” Lew said in an interview — especially, he added, “when you’re faced with the alternative of 3.5 million Americans being plunged into chaos.”

“The real alternative was not a better bill,” he said. “The real alternative was no bill.”

After meeting with nine Democratic senators Tuesday, García Padilla said in a statement that, while “imperfect,” the House-drafted bill offered “an orderly debt restructuring process and a real opportunity of negotiation with creditors” and that “the crisis . . . will worsen if the Senate does not take immediate action.”

In an op-ed published on CNBC’s website, the governor added: “PROMESA has its downsides. It creates an oversight board that unnecessarily undercuts the democratic institution of the Commonwealth of Puerto Rico. But facing the upsides and downsides of the bill, it gives Puerto Rico no true choice at this point in time.”

As the clock winds down toward the July 1 deadline, there is considerable confusion about Puerto Rico’s cash position. Many creditors and analysts believe the territory has enough cash to at least make the $300 million or so in interest payments on Puerto Rico’s general obligation bonds, generally considered one of the safest bonds. But other analysts say that even if Puerto Rico could make interest payments, failure to make the principal payments coming due would still constitute a default and would leave the island’s coffers virtually empty.

Even if the island scraped together $300 million for interest payments now, there would be an additional $2 billion of interest payments due over the next fiscal year. In addition, Puerto Rico usually receives more cash toward the end of its fiscal year, so any recent influx of cash would not recur until next spring.

“Maybe they’re trying to show good faith,” said Susheel Kirpalani, a bankruptcy expert and partner at Quinn Emanuel Urquhart & Sullivan representing one category of bondholders. But, he added, “in restructuring, the first rule is cash is king. To pay interest would be 180 degrees opposite of Restructuring 101.”

Ted Hampton, vice president of Moody’s, said in the ratings agency’s most recent report on the territory: “We expect Puerto Rico will continue to default on a growing number of its security types as time goes on, in view of its strained liquidity.”

Kirpalani said that various creditor groups, including his, were ready to meet again with the commonwealth’s financial advisers to narrow differences. “We can’t assume the oversight board will be able to move from a standstill to a sprint,” he said.

Puerto Rico’s fiscal crisis goes deeper than its unsustainable public debt: Its economy has been stagnant for years, and its population has been steadily fleeing to the U.S. mainland — eroding the territorial tax base and threatening the delivery of basic services. More than a third of territorial government revenues are now spent on debt service.

“There can be no economic growth in Puerto Rico until the debt is restructured, so the legislation is an absolutely essential first step,” said Eric LeCompte, executive director of Jubilee USA, a network of mainly religious advocacy groups focused on global debt relief. “But I think in terms of the real issues facing the island, we are just getting to the end of the beginning. This is not the beginning of the end.”

In the near term, LeCompte said, the appointments to the oversight board will have significant bearing on Puerto Rico’s path forward. Over the longer term, the island faces bigger questions about how it can reverse its economic decline and whether to revisit its status as a U.S. territory.

In Puerto Rico, there are still many concerns about the legislation, which was inspired in part by the federal control board Congress imposed on Washington, D.C., from 1995 to 2000. Sergio Marxuach, public policy director at the San Juan-based Center for a New Economy, says that in the District’s case the federal government later took over a sizable chunk of unfunded pension obligations, whereas Puerto Rico faces about $43 billion of unfunded pension liabilities once it gets past its $72 billion or so of other debts.

PROMESA also allows the oversight board to accelerate investment projects, and Marxuach fears that the board’s haste might make for wasteful choices, especially when it comes to new energy projects.  “We don’t use the phrase ‘humanitarian crisis,’ ” he said. “It’s a fiscal and economic crisis with the potential to get there.”

Top Democratic leaders supported the bill — if grudgingly.

“If Democrats had written this bill, it would be very different than what we are voting on today,” Senate Minority Leader Harry M. Reid (D-Nev.) said Wednesday. “But I’m going to vote for passage of this bill because we must help Puerto Rico before July 1st. Otherwise we turn that island . . . over to the hedge funds, and they’ll sue them to death.”

But there were several vocal holdouts — including Sen. Robert Menendez (D-N.J.), who spent more than four hours on the Senate floor Tuesday railing against the bill, arguing that it would strip Puerto Ricans of their political rights and would not offer a sure-enough path to fiscal stability for the island.

Also vowing to oppose the bill was Democratic presidential candidate Bernie Sanders (Vt.), who said he would “do everything I can to defeat a horrific bill.” An added complication was a bipartisan group of senators representing coal-producing states who said they would oppose closing debate on the Puerto Rico bill unless they won assurances from McConnell that the Senate would act to shore up health and pension funds for mine workers.

Menendez, who called for amendments to the bill, played down the urgency of the situation. “There is no precedent to suggest that Puerto Rico would not be able to fund essential services while we worked to get the bill right over the next few days,” he said.

But other senators said they were convinced a default would be disastrous — including the possibility that creditors could rush to court and secure judgments, leaving the territory without cash to pay essential personnel such as teachers and emergency responders.

“We’re not going to let Puerto Rico go off the cliff here,” Sen. Marco Rubio (R-Fla.) said Monday. “It’s too important.”