CitgoAmber Energy, an affiliate of Elliott Investment Management L.P., will acquire Citgo for nearly $5.9 billion.

A judge has approved the sale of Citgo, a Houston-based petroleum company, to Amber Energy following a years-long legal saga.

A court previously found that Citgo’s shares could be auctioned to pay off the debts that its state-owned parent company – Petroleos de Venezuela – owed to a Canadian mining company.

J.P. Duffy is an international arbitration partner at the New York-based law firm Bracewell. He said the Venezuelan government faced mounting debts, as the country grappled with falling oil prices and political instability.

Sign up for the Hello, Houston! daily newsletter to get local reports like this delivered directly to your inbox.

“Venezuela found itself the subject of a lot of legal actions that were allowed to proceed against [it] and found itself owing billions of dollars to foreign creditors,” he said. “And some of those debts it had actually secured with the shares of Citgo’s parent company.”

Duffy said the Venezuelan government still has other debts to repay.

“This is probably the beginning of something that will go on for a very, very, very long time,” he said.

RELATED: Houston-area brothers sue Citgo for $400 million over imprisonment in Venezuela

Amber Energy, an affiliate of Elliott Investment Management L.P., will acquire Citgo for nearly $5.9 billion. The acquisition is expected to be finalized sometime next year.

“We look forward to working with the talented CITGO team to strengthen the business through capital investment and operational excellence,” Amber Energy CEO Gregory Goff said in a news release. “I am confident that together we will help enhance America’s energy leadership position.”

Citgo employs 3,300 people, operating refineries in Corpus Christi, Lake Charles, Louisiana, and Lemont, Illinois.

“Together we will have the scale, the resources and the reach to grow strategically and create new opportunities for our people and our customers,” Goff said in a video posted to Amber Energy’s website.

Amber Energy plans to maintain Citgo’s refineries, rather than immediately selling them, once the acquisition is complete, according to Reuters. Venezuela’s Vice President and Oil Minister Delcy Rodriguez said the country rejects Citgo’s sale and filed an appeal in the court case, the news outlet reported.