Italian Prime Minister Giorgia Meloni visited Tripoli on Saturday to conclude an $8 billion gas deal aimed at boosting energy supplies to Europe despite the insecurity and political chaos in the North African country.

Meloni met Libya’s Prime Minister Abdulhamid al-Dbeibah, head of the internationally recognised Government of National Unity (GNU) in Tripoli, before the energy deal was signed for talks that also focused on migration across the Mediterranean.

Signing the deal, Libya’s National Oil Corp (NOC) chief Farhat Bengdara and the head of Italy’s EniENI.MI, Claudio Descalzi, said they will invest $8 billion in gas development, as well as in solar power and carbon capture.

European countries have increasingly sought to replace Russian gas with energy supplies from North Africa and elsewhere over the past year because of the war in Ukraine.

Italy has already taken a lead in sourcing gas from Algeria, building a new strategic partnership there that includes investment to help state energy company Sonatrach reverse years of declining output.

Bengdara said the 25-year gas agreement would lead to output of up to 800 million cubic feet a day, calling it the most important new investment in Libya’s energy sector for a quarter of a century.

However, agreements struck in Tripoli may be undermined by Libya’s internal conflict, which has divided the country between rival factions who vie for control of government and dispute each other’s claims to political legitimacy.

Underscoring the uncertainty, Dbeibah’s own Oil Minister Mohamed Oun has rejected any deal that NOC might strike with Italy, saying in a video on the ministry website that such agreements should be made by the ministry.

NOC chief Bengdara was appointed last year by Dbeibah, whose own interim government was installed in 2021 through a U.N.-backed process.

The eastern-based parliament and factions that support it said early last year that the government was no longer legitimate, rejecting both the appointment of Bengdara and deals that Tripoli has struck with foreign states.

Chaos in Libya since the 2011 NATO-backed uprising that ousted autocrat Muammar Gaddafi has left much of the country in the hands of armed factions. A small Italian military mission has been deployed in Libya for several years.

Dbeibah and Meloni said they had also discussed the issue of illegal migration from Libya to Italy. Rome will support Libya by providing new search and rescue ships, Dbeibah said.

Insecurity and lawlessness has made Libya a major, but dangerous, route for migrants seeking to reach Europe, often via the Italian island of Lampedusa. Hundreds of migrants die each year attempting to make the journey.

Meloni has made tackling illegal migration a major plank of her governing agenda and she has pushed the issue in recent visits to Algeria and Egypt. Italian Interior Minister Matteo Piantedosi, who oversees much of the migration issue for Rome, flew to Libya with Meloni.