The Islamic State usually attacks Libya's Brigade 166 after dark. Sometimes its fighters walk as far as 10 miles from bases in the port city of Sirte to launch surprise strikes on the unit, a militia loyal to the country's Tripoli government. At others, they detonate suicide car bombs at checkpoints, often in the early hours of the morning.

These clandestine tactics have proven difficult to deal with, the brigade's head of operations Suliman Ali Mousa told VICE News during a recent visit to its sprawling base on the outskirts of the city.

"We cannot predict what they'll do, [so] we are on standby all the time and at night, nobody sleeps," the rangy 60-year-old said, stroking his white beard and leaning over a dusty conference table in a prefab-turned office.

IS struck earlier that day. A jihadist — identified by the group as a Sudanese national — killed at least six people, including civilians, when he detonated a vehicle containing an improvised explosive device at a checkpoint on the road that leads from Misrata to Sirte between the white sands of the Mediterranean coast and Libya's barren, scrub-spotted interior.

A team of workmen was quickly deployed to plaster and paint over the damage, but the effects of the blast were still clearly visible in the fragmentation-scarred overpass, large half-bulldozed crater, and charred skeleton of a minibus dragged off to the side of the road.

There was fighting outside Brigade 166's base that night too — sporadic gunfire from dusk onwards and the occasional boom of large caliber weapons as the militia fighters fired on IS positions inside Sirte.

Libya's security situation has been precarious since longtime dictator Muammar Qaddafi was overthrown in 2011's armed uprising, but conditions deteriorated still further last year. The country is now split between two warring administrations: the older Islamist-dominated and Tripoli-based General National Congress (GNC), and the House of Representatives (HOR), which gained international recognition after elections in 2014.

The GNC refused to accept the ballot results, and seized the capital with its Libya Dawn militia coalition. The HOR subsequently fled east to Tobruk, where it still remains, backed by a group of army remnants and allied militias led by Gen. Khalifa Haftar. Fighting between the two sides over oil, money, and power has crippled the country, which is now seemingly lurching toward complete collapse.

Amid the turmoil, IS seized the opportunity to expand its self-styled caliphate from strongholds in Syria and Iraq, where it is under increasing pressure from a US-led coalition targeting it with heavy airstrikes. Libya — oil-rich, barely governed, and flooded with weapons looted from government stores in 2011 — was an obvious mark.

The jihadists now control Sirte, as well as Derna further down the coast and are also believed to have a presence in Benghazi. They have claimed responsibility for attacks that killed dozens on both sides of the Libyan conflict as well as a number of strikes on foreign targets in the country, including Tripoli's luxury Corinthia Hotel and the South Korean embassy.

A number of oil fields have now shut down after IS assaults in which several international workers were taken hostage and a number of Libyans killed.

In February, the group chose a characteristically bloodthirsty way to announce its presence as a major force in Libya with the release of a grim propaganda video showing the beheading of 21 Egyptian Coptic Christians kidnapped from Sirte.

Several extremist groups operating in Libya have pledged allegiance to IS leader Abu Bakr al Baghdadi. In many cases, this has likely been in the hope of benefitting from its fearsome reputation, rather than through any close contact with leadership. The Sirte contingent, however, appears to be coordinating closely with senior figures in Iraq and Syria.

IS propaganda and recruitment magazine Dabiq published pictures of the captured Egyptians before their murder, and the style of the execution video was markedly similar to others filmed in Syria. Mohammed Omar Hassan, the 28-year-old leader of Brigade 166, told VICE News that its prominent Bahraini cleric Turki al Binali had even visited Sirte to preach.

Qaddafi was born near Sirte, and the embattled dictator made his last stand there before being captured and killed during concentrated urban fighting that devastated the city. Loyalist militias holed up in the Ouagadougou Conference Center in the final stages of the battle. But the building is now painted with IS's black flag and used as a base by a force that Libyan commanders say is around 300 strong and comprised of both Libyans and foreigners.

Brigade 166 was deployed to Sirte in February, tasked by Libya Dawn leaders to deal with IS's presence there. Like most of the powerful militias in the Tripoli-based coalition, it's based in Misrata.

Mousa, himself a 43-year military veteran, said its men are a mix of hardened revolutionary fighters and "professional" soldiers who trained in Europe and the US as members of the pre-2011 Libyan army. But some are clearly too young to have received instruction abroad under Qaddafi, and others look too youthful even to have fought in the revolution. Hassan himself used to work on construction sites. His father now heads a group of seven brigades, including 166

But the brigade easily outguns IS and possesses large stocks of weaponry, including numerous pieces of pickup truck-mounted artillery and at least three aged Russian-made tanks. Their base also has a medical clinic and a number of ambulances, as well as a mobile command center in a camouflage-painted GMC truck.

But it has not been quick to take the fight to IS. The two forces existed in a state of virtual ceasefire for some time, with clashes only erupting in mid-March.

Hassan, the brigade's commander, said his men currently have Sirte surrounded and maintain a presence at all access points.

But they stay well clear of the city itself. Instead of taking the fastest route to their base, the militiamen use the red sand-covered roads that circle around Sirte through half-cultivated fields and unfinished houses.

Mousa said the better armed and equipped Libya Dawn force has moved slowly against IS because it has been conducting surveillance and drawing up rules of engagement to avoid civilian casualties. Its men have even conducted reconnaissance missions inside the city while disguised as farmers, he said, going to claim that Hassan was on one such sortie when VICE News arrived at the base. The 166 head later appeared back at the base in uniform.

"It's a city, not open desert, and there has to be execution plans to work inside cities… Our number one priority is to preserve and protect the lives of civilians," Mousa said. "Our second is to protect vital installations and buildings and preserve the environment."

He added that the brigade has attempted to confine fighting to certain quarters of the city. "It's like a patient who needs a quick surgical procedure," he explained, employing what turned out to be a favored medical analogy.

The brigade has now imposed a nighttime curfew on Sirte and urged families around IS strongpoints to evacuate their homes. But leaders admit that the militants enjoy some local support, potentially because of resentment at the destruction wrought on the city by Misrata-based militias in 2011.

Hassan insisted that progress is being made, and reported that IS had now been pushed out of their base in the Ouagadougou center. But 166 has refrained from advancing further to avoid casualties, both to themselves and civilians, he said.

Militia members claimed to have killed a number of IS fighters in recent days — including Libyan, Tunisian, Egyptian, Sudanese, and Mauritanian nationals — and captured four others, including three foreigners. Brigade 166 only suffered minor casualties in return, Mousa said, adding that most were "lightly wounded." Other sources reported seeing the bodies of several Libya Dawn fighters being carried away from the front.

VICE News witnessed militia members arriving in a Toyota pickup after a night's fighting with a stack of what they said were Libyan and foreign passports taken from dead jihadists wedged on the dashboard. They would not allow the documents to be inspected, citing security reasons.

Brigade 166 does not always appear to be the crack fighting unit its leaders claim. The Sirte base was barely stirring by midday and central areas appeared lightly guarded. Checkpoints in and out of the area have still not been adapted to deal with the regular car bombings. Most look more like easy targets than deterrents, with no way to slow approaching vehicles and sleepy looking young men in mismatched uniforms and flip-flops milling around carelessly. An escort convoy into the base consisted of pickup trucks loaded mostly with unarmed fighters and stacks of ammunition boxes.

Their will to fight does not match the fanaticism of their enemies. Mousa is a fan of Martin Luther King and at one point referenced his 1963 "I Have a Dream" address. "It was a great speech," he said wistfully.

"I need a holiday," he added later. "I really need one. I'm tired. I want to be with my wife. My wife and my birds." He sighed sadly before brightening up for a few minutes while talking about his 150 canaries.

Nevertheless, Hassan, perhaps optimistically, predicted that the operation in Sirte would be finished in a matter of days. IS is a threat to the whole country, he said, and must be dealt with.

Until recently, Libya Dawn officials denied that the militant group even existed in Libya, instead claiming that they were in fact members of Qaddafi's clan, or fighters loyal to Haftar using IS identity as a front.

To bolster their argument, many reference a television interview with Qaddafi's exiled cousin and former aide, Ahmed Qaddaf al Dam, in which he praised IS for dissolving Western-imposed national borders between Iraq and Syria. Later in the interview, however, al Dam condemned its brutality and extreme religious conservatism.

Officials in Tripoli now admit that there is an IS presence in the country, but continue to maintain that many of its members are regime loyalists and what GNC member Mohammed Busidra, 56, described to VICE News as "fake Daesh," using the Arabic acronym for IS.

Busidra, an Islamist who studied biochemistry in the UK before being imprisoned for more than two decades by Qaddafi, denied that IS now has a foothold in Libya, insisting that parts of Europe have a bigger problem with the group.

"You cannot say that Libya is a base of Daesh, it is in France, more than Libya," he claimed.

He even alleged that the Egyptian Christians were not in fact killed by IS, instead calling the execution footage "a Hollywood-style production."

Asked for proof, he pointed to the victims' apparent compliance with their executioners and said that one of the killers wore a watch on his left wrist, violating an edict rumoured to have been issued by Baghdadi that timepieces should only be worn on the right.

"Do you really believe that they were killed?" he asked. "For ourselves we find it very difficult to believe it. Up to now, I don't believe it. I want some independent and authentic source to prove that."

Busidra is a controversial figure, but other GNC members, including recently sacked Prime Minister Omar al Hassi, have made similar statements in the past.

Libya Dawn's reluctance to acknowledge IS's existence within their borders may be motivated in part by the fact that its alliance also includes armed factions with extremist ideologies, particularly those battling Haftar's forces in and around Benghazi and Derna. The most prominent of these is Ansar al Sharia, which has been accused of mass killings in Benghazi and is widely believed to be responsible for the 2012 attack on the US consulate there that killed Ambassador Christopher Stevens.

Hassan said IS's presence in Sirte is the direct result of Ansar al Sharia seizing the city in 2013, adding that many of its members have now joined the newcomers.

"[Ansar al Sharia] are the reason why IS entered Sirte and they are the ones who pledged allegiance to them," he said, adding that a former Ansar member is now IS's "emir" in the city.

Other Libya Dawn members deny that Ansar al Sharia has links with IS, perhaps in part because the Libyan group emerged from the fighters that occupied Sirte after Qaddafi's death. Hassan's father Omar said the international community has portrayed a "false image" of Ansar al Sharia.

Meeting with VICE News late one evening on the top floor of a smoky Misrata cafe, he whispered with his suit-clad aide-de-camp before answering a question about the militants, and avoided labeling them as anything other than religiously conservative. IS's presence in Sirte, he said, is instead the fault of Qaddafi regime sympathizers.

Busidra also described Ansar al Sharia as "revolutionaries" and said he would need hard legal evidence against them to believe that they were capable of crimes, something that is virtually impossible under the current circumstances.

"They couldn't prove one case against Ansar al Sharia," he said, adding that he questioned its leaders himself. "They're friends of mine, I was in prison with them. I asked them, 'Did you have anything to do with these killings, if so then why?' They said 'If you find certain clues we were behind it, then come and face us.'"

Back in Sirte, Brigade 166 leaders say they now classify Ansar al Sharia and IS members as terrorists and adherents of a "foreign" ideology that is alien to Libyans and to Islam. Both Hassan and Mousa said they're even keen to see a diplomatic solution between the Tripoli government and administration in the East, admitting that Haftar's men are also battling IS for the same reasons.

"Anyone who claims Islamic extremism," Mousa said emphatically, "their heads should be chopped off."