Wills Eye Hospital on Thursday regained its status as a hospital under Medicare, a major gain for the Center City institution that will enable it to perform complex surgeries that take more than four hours and to receive higher Medicare rates than it could as an ambulatory surgery center.

The decision by the federal Centers for Medicare & Medicaid Services came two months after the nonprofit, which is owned by Philadelphia's Board of Directors of City Trusts, lost a legal fight over its status in federal court in Philadelphia.

"We are pleased to learn of the CMS decision," Wills said in a statement. "We very much appreciate the tireless efforts of our senators and the Pennsylvania congressional delegation to advocate for the patients of Wills Eye Hospital. We are grateful to CMS to have the opportunity to move forward, and we remain committed to providing the highest level hospital care to our patients."

The financial implications are significant. According to the Ambulatory Surgery Center Association in 2016, Medicare pays hospitals $1,745 for an outpatient cataract surgery while paying surgery centers only $976 for the same surgery. Wills had an operating loss of $9.1 million on revenue of $64.6 million in the year ended June 30.

Pennsylvania's U.S. senators praised the agency's action.

"The decision by CMS will help preserve access to high-quality, complex eye care for patients in the Philadelphia region and beyond at this respected institution," said U.S. Sen. Pat Toomey (R., Pa.).

Wills' predicament dates to July 2006, when it sold its inpatient business to Thomas Jefferson University Hospital, operating instead as an ambulatory surgery center at Eighth and Walnut Streets. But it was not long before Wills management changed course and undertook a $6.5 million renovation in 2013 that included a four-bed inpatient unit.

Medicare officials, however, rejected Wills' bid to regain certification as a hospital, finding that it treated too few inpatients relative to its number of outpatients to qualify as a hospital.

Wills repeatedly argued that CMS officials made an arbitrary decision that, if applied broadly, would prevent many high-profile hospitals from participating in Medicare.

Between 2013 and 2016, Medicare certified at least 30 hospitals with 10 or fewer beds, including a one-bed hospital in Minnesota, according to agency data.

Wills' major East Coast competitors — Anne Bates Leach Eye Hospital, part of the University of Miami Health System; the Wilmer Eye Institute in Baltimore; Massachusetts Eye and Ear in Boston — all had very low percentages of inpatient care and were still certified as hospitals.

But Wills lost at every level of appeal, including in October 2016 at the final stage within CMS. After that decision, Wills had to stop keeping patients for more than 24 hours. Such patients started going to Jefferson.

Wills last week took its legal fight to the U.S. Court of Appeals for the Third Circuit, all the while hoping for relief from a September change in regulatory guidance on what qualifies as a hospital.

The guidance said that "hospitals are not required to have a specific inpatient-to-outpatient ratio" to meet the criteria as a hospital.