As the deadline for the formation of a government of national unity in Libya expired on January 17, the recent attacks carried out by the Islamic State of Iraq and the Levant (ISIL) group, throw into question the new government's capacity to provide security for the country.

A peace agreement was signed on December 17 in which representatives from Libya's two rival governments - the internationally recognised administration in Bayda and the unofficial Government of National Salvation in Tripoli - agreed on the creation of a Government of National Accord (GNA) within 30 days.

However, a series of devastating ISIL attacks rocked the country over a 10-day period beginning on January 4 and leading up to the January 16 deadline for the formation of the new government.

WATCH: A breakthrough in Libya?

Between January 4 and 6, the group hit the oil infrastructure on which the country's future economic prosperity relies. Two oil export terminals were targeted along the Mediterranean coast, at Es Sider and Ras Lanuf.

The facilities have a combined oil processing capacity of up to 700,000 barrels per day (bpd). Libya is currently producing less than 400,000 bpd, down from 1.6 million before the ousting of former leader Muammar Gaddafi in 2011.

Even if the new government is formed, which is possible, it is difficult to say it will be able to function. Mohamed Eljarh, political analyst at the US-based Atlantic Council

Car bombs were detonated at the gates of the terminals and shells were fired at oil storage units. The attacks killed 18 personnel from the Petroleum Facilities Guard (PFG), the militia responsible for protecting Libya's oil infrastructure, and set seven oil terminals ablaze.

Each of the storage tanks contained an estimated 420,000-460,000 barrels of crude oil. The following day, on January 7, a truck bomb targeting a police training centre in Zliten, about 160km east of the capital, Tripoli, killed at least 65 people and wounded more than 100.

It was the most devastating terrorist attack in Libya's history.

A power plant in Libya's second city, Benghazi, has also succumbed to an ISIL attack in recent days cutting electricity supply to houses and vital services such as hospitals.

On January 14, there were two more attacks against oil infrastructure: one against a pipeline south of Ras Lanuf, and the other a shooting at a checkpoint outside the Mellitah oil terminal in the northwest, operated by Italy's energy giant, Eni.

ISIL, say analysts, has been spreading its influence along the Mediterranean coast for several months. It has made the coastal oil town of Sirte its headquarters - having been ousted from Derna by rival Islamist groups in June - and has taken over the towns of Harawa, about 60km east of Sirte, Nufaliya, about 130km east of Sirte, and, most recently, Bin Jawad, another 20km east along the coast towards Es Sider.

The group is also fighting for supremacy in another key oil town, Ajdabiya, which would give it access to two more oil export terminals: Zueitina and Marsa el-Brega. ISIL launched a marine attack on Zueitina on January 10, but was repelled by the PFG.

ISIL has targeted oil infrastructure before. In March 2015, National Oil Corporation, the state oil company, was forced to declare force majeure on 11 oilfields in the Sirte basin, Libya's oil-producing heartland, after a series of attacks on the fields.

The latest attacks, however, are by far the most worrying. Ras Lanuf and Es Sider are among the largest oil export terminals in the country, and the prospect of a resumption of shipments from the two facilities (which have been closed since December 2014 owing to fighting between forces loyal to the two rival governments) has been lauded as one of the quickest ways for Libya to get its economy back on track.

ISIL struck the Es Sider terminal in October 2015, but did little more than attack the guards. Now, the armed group has proven that it can damage the terminals, hitting prospects of their reopening any time soon.

Mellitah and Marsa el-Brega are two of only three currently functioning oil terminals - the third being Hariga in the northeast. If either or both of these are forced to close, it would further erode an economy heading rapidly towards bankruptcy.

Q&A: Libya crisis explained

The implementation of the December 17 deal has already hit problems. It is yet to be endorsed by the House of Representatives (HoR), the Tobruk-based parliament attached to the government in Bayda. The heads of both the HoR and the General National Congress, the unofficial parliament in Tripoli, have spoken out against the agreement.

A nine-member presidential council has been appointed, headed by prime minister-delegate Fayez Sarraj. On January 14, the council appointed a security team to arrange for the relocation of the GNA from Tunis to Tripoli.

But the likelihood that the new government can resolve the security problems of a country not only targeted by ISIL but also divided between hundreds of often-competing militias is remote.

The Bayda government has relied - in large part - on the military might of Khalifa Haftar, head of a group of militias known collectively as the Libyan National Army, and Ibrahim Jadhran, the head of the PFG.

Both men have often acted on their own initiative, and neither has been a proponent of the peace talks that culminated in the GNA.

Worse still, Haftar's priority in the past 18 months has been to wipe out Islamist opposition to the HoR, however moderate - and Haftar and Jadhran themselves are rivals.

"Even if the new government is formed, which is possible, it is difficult to say it will be able to function," says Mohamed Eljarh, a Libyan national and non-resident fellow at the Atlantic Council's Rafik Hariri Centre for the Middle East.

"It might be able to move to Tripoli, but it will be difficult to exercise control over Libya. Given the realities on the ground, it is extremely difficult to imagine all the different groups being brought under one umbrella."

Richard Mallinson, geopolitical analyst for Energy Aspects, agrees: "We're a long way from a credible Libyan military under the authority of the government," he says.

"Just as getting from an agreement on the formation of a unity government to establishing a government is a long and rocky path, the same has to be said for establishing a true national army, which is a concern for the rest of North Africa, and even for Europe."

If Libya's disparate armed forces are unable to pull in the same direction, and quickly, the growing threat of ISIL is likely to become increasingly unmanageable.