Argentina's senate has approved the forced takeover of the country's biggest oil company, underscoring broad domestic support that has caused outrage among foreign investors.
The expropriation bill passed easily in the elected body after midnight on Thursday morning, with 63 senators voting in favour of the expropriation, only three voting against the bill and four abstentions.
The early morning vote was held after a marathon debate that started around midday on Wednesday.
The bill now has a clear path for likely approval by the country's lower house sometime next week.
President Cristina Fernandez de Kirchner, who is allied with both houses of congress, unveiled plans last week to seize a 51 per cent stake of YPF from Spain's Repsol.
Kirchner accused Repsol of draining YPF since gaining control in the 1990s, under-investing in its oil and gas fields and failing to keep pace with the needs of Argentina's growing economy even as it paid huge dividends to shareholders.
Repsol blames Argentina's ever-changing mix of subsidies, price caps and export taxes for depressing production as the country's demand for energy soared since 2003, when her husband, President Nestor Kirchner, came to power.
Only two months ago, Repsol YPF upped its estimate for the shale oil and gas it found in Argentina to nearly 23 billion barrels, enough to double the country's output in a decade.
But the Spanish company said it would cost $25bn a year to develop, and warned that Argentina would need to overhaul its energy policy to attract the necessary investment.
Hugely popular decision
Taking back Argentina's largest company from Spain's biggest company has proven hugely popular in the South American country, despite threats of retaliation from the Europe Union and fears of unintended consequences in the years ahead.
Most Argentines support the move to renationalise YPF, which was privatised in the 1990's after 70 years under full state control.
Many blame the privatisations and other free-market reforms of that decade for provoking Argentina's 2001/02 financial meltdown.
The senate session started late morning Wednesday and was continuing 14 hours later as 62 of the Senate's 72 members asked to speak about the proposal.
"The government's bill doesn't reflect a capricious or random decision," Marcelo Fuentes, a ruling party senator, said during the debate.
"It's a logical result stemming from the need to reverse free-market thinking in energy policy."
Once the takeover becomes law, attention will turn to the compensation Argentina will pay Repsol for its majority stake in YPF.
Officials have already said it will be far lower than the $9.3bn the company has requested.
But by re-nationalizing YPF - and not paying Repsol until international courts resolve the case years from now, if ever - Argentina can reinvest profits to develop new reserves and use the fuel Repsol was exporting to save consumers from price shocks as it weans them off the subsidies.