It is a beautiful sandy beach and emerald green waves roll in from the Mediterranean Sea. The coast of Misrata goes on for kilometres and as I look into the distance I see nothing but blue skies, yellow sand and that green sea.

I am here following a patrol from the local coastguard who are looking for Islamic State of Iraq and the Levant (ISIL, also known as ISIS) fighters who use the beach to bring in drugs, weapons and reinforcements. Libya has one of the longest stretches of unspoilt coastline in North Africa.

It runs nearly 1,800km across the roof of the continent and because of that openness, it's incredibly difficult to defend, but defend it they try. The coastguard uses a variety of means, including the land patrol I am on -and by sea and air.

I ask one of the soldiers, Jaber Lamlahaq, about what the biggest threat they face is.

"It's from the former Gaddafi soldiers who have joined forces with ISIL. They know the territory very well and how we operate so they are a dangerous force. ISIL, we are not really worried about. They don't really fight with us. Everytime we see them they retreat," he said.

Joining forces with locals that used to be the enemy is not an uncommon strategy for ISIL.

In Iraq, in Saddam Hussein's home town of Tikrit, it was former Republican Guard soldiers loyal to the deposed dictator that had trained a new generation of fighters that defended the city before it fell to the Iraqi army.

They fought under the black flag of ISIL, not because they believed in the caliphate but because it was a flag of convenience.

ISIL had the ability to fund a war and to encourage international support for their cause. If you're looking for backing for a fight, ISIL has the ability to give you that. In both Libya and Iraq, ISIL accepted former government soldiers because of their local knowledge and the former government fighters accepted the hardline religious ideology as part of the cost of war.

Jaber says the former Gaddafi soldiers have nothing in common with ISIL fighters. "The Gaddafi soldiers drink, they take drugs. All they care about is power and money. They are not practising Muslims. ISIL care about power and killing other Muslims that don't agree with them. It's not an alliance that will last."

For now though it is an alliance that will last because ISIL and the Gaddafi loyalists have a common goal. But even if they reach that goal of overthrowing Libya's revolutionary forces it's likely that after they will turn the guns on each other.

As I look out across the Mediterranean and into the distant coastline I see hazy figures in the distance. I ask if Gaddafi loyalists can be seen from here. "Not during the day" is the reply I get. I jokingly say maybe it was the ghosts of Gaddafi I saw. No one laughs.

The former government soldiers present a clear and present danger to the Libyans. Dealing with them is just one more challenge of the myriad of problems this country faces.

Follow Imran Khan on twitter @ajimran

Source: Al Jazeera