Image copyright Reuters Image caption Argentina had accused YPF of not investing enough to increase output

Spanish oil company Repsol has agreed a $5bn (£3bn) settlement with Argentina over the seizure of its assets there.

Argentina nationalised Repsol's stake in the country's biggest oil firm, YPF, in 2012, stripping Repsol of nearly half its annual output.

The Spanish firm had been demanding $10.5bn in compensation.

Although the amount agreed is half that figure, Repsol said it was a positive move as it would end legal uncertainty and give the firm a financial boost.

"I think to finally reach a friendly agreement on this contentious issue that has taken two years is extremely positive," said Antonio Brufau, Repsol's chairman.

"As far as we are concerned, from a financial point of view, we have started a new chapter where we are stronger."

Argentina will pay Repsol using US dollar-denominated government bonds, which the Spanish firm can sell at any time.

Boost for Argentina

YPF is a fundamental tool for the country's energy future and I believe the expropriation has given that tool back to Argentines Miguel Galuccio, YPF

The move is also expected to help Argentina attract foreign investment in its shale oil and gas reserves, which are among the world's largest.

YPF produces about a third of Argentina's oil and a quarter of its gas.

The country has been keen to develop the Vaca Muerta shale formation - a key YPF asset - but has so far struggled to attract investors, not least due to the uncertainty over the legal proceedings with Repsol.

As part of the settlement, Repsol has agreed to drop its lawsuits against Argentina.

Miguel Galuccio, president of YPF, said the deal was a positive development for Argentina's economy.

"YPF is a fundamental tool for the country's energy future and I believe the expropriation has given that tool back to Argentines."

The deal still needs to be approved by Repsol's shareholders and by the Argentine parliament.