CARACAS, Venezuela (AP) — A U.S. judge on Friday approved moving forward with the sale of Venezuela’s prized U.S.-based CITGO refineries, allowing a Canadian mining company to collect $1.4 billion it lost in a decade-old takeover in the South American nation by the late socialist President Hugo Chávez.

The ruling strikes a blow to Venezuela’s opposition led by Juan Guaidó, which was banking on profits from the Houston-based company to finance the crisis-torn nation’s recovery — if they were ever able to force President Nicolás Maduro from power.

The order by Chief Judge Leonard P. Stark of U.S. District Court in Delaware follows a decision by the U.S. Supreme Court on Monday that upheld an earlier ruling by Stark authorizing CITGO’s liquidation.

Before moving ahead with CITGO’s sale, the bankrupt Canadian mining company Crystallex must first get a license from U.S. Treasury officials, which had temporarily shielded Venezuela’s opposition from losing CITGO.

Crystallex and attorneys for Venezuela also have to agree on how it will sell CITGO, Stark’s latest ruling said.

Chavez took over the gold mining firm’s Venezuela concession and the local operations of other international companies as part of his Bolivarian revolution that has left Venezuela spiraling into deepening economic and political turmoil.

Crystallex, which went bankrupt, sued Venezuela to recover its lost investment in Venezuela. The case is unique, because the court allowed Crystallex to attach assets of CITGO’s parent company, the Venezuelan state-run oil firm PDVSA, finding that Venezuela had erased the lines between the government and its oil firm.

Venezuela has owned CITGO since the 1980s as part of PDVSA. It has three refineries in Louisiana, Texas and Illinois in addition to a network of pipelines crisscrossing 23 states. It provides between 5% and 10% of U.S. gasoline.

Guaidó, the head of Venezuela’s opposition-led National Assembly, claimed presidential powers in early 2019, vowing to end Maduro’s rule and two decades of socialist leadership.

After the Trump administration recognized Guaidó as Venezuela’s legitimate leader, U.S. courts granted approval to a board appointed by the opposition to take control of CITGO, valued at an estimated $8 billion. However, more than a year later, Maduro remains in power, with firm military support at home and backing from key international allies including Russia, China and Iran.