Updated

Legislators in Puerto Rico have approved a last-minute bill needed to finalize a deal to restructure the U.S. territory's heavily indebted public power company.

The measure barely passed late Monday with the minimum 26 votes needed from the island's House of Representatives. Another 22 legislators voted against the bill, which seeks to reduce the company's $9 billion debt as well as diversify energy resources and boost public-private partnerships to overhaul aging infrastructure at the largest U.S. public power utility.

Bondholders had threatened to go to court if the bill was not approved by Tuesday's deadline.

The Puerto Rico Electric Power Authority reached a restructuring deal late last month with bondholders. The company warned it would run out of cash by summer without debt restructuring.