They appeared overnight on the horizon last June, and they are still clearly visible from the road to Baghdad. Today, the black flags of the "Islamic State" group (IS) align its current boundaries at this point, 200 kilometers (124 miles) north of the Iraqi capital. "There is no god but Allah, and Muhammad is his prophet," can be read on the flapping pieces of cloth.

A few meters away, diggers work non-stop in Matara, a small village on the Kurdish side of this increasingly well-delineated border. Ditches are dug and earth walls erected across the positions guarded by an improbable contingent: Iraqi Kurdish soldiers - peshmerga - and Kurdistan Workers Party (PKK) fighters. They fought each other back in the 1990s, but a powerful common enemy brought them together last August.

"When we saw that Daesh [The Arabic acronym for the "Islamic State"] was at the gates of Kirkuk we thought they needed us here," PKK commander Heval Agid - "comrade Agid" in Kurdish - tells DW. "The situation was so dire that even the local people asked us to come," recalls the guerrilla fighter from the half-finished apartment that is now the headquarters of his unit.

To the north of Baghdad, Kirkuk has its foundations in one of the largest oil reserves in the Middle East. While Arabs and Kurds struggled in vain over the past decade to control the city, a third actor appeared on the scene. Today, Kirkuk is not only the thorniest issue in relations between Baghdad and Irbil, the seat of the Kurdish Regional Government, it may also be a last strategic step for the jihadis on their way to the country's capital.

Since they took over Mosul, Iraq's second city, in June, IS has proven to be a very strong enemy, with tens of thousands of fighters and heavy weaponry, much of it captured from the US-armed Iraqi army, but also from the Syrian regime

Commander Agid, who joined the PKK 18 years ago, is among those determined to stop the advance of such a powerful adversary. He relies on an armed body with numbers ranging between 100 and 300, "depending on the needs." They appear to become more pressing as the sun goes down.

PKK Commander Agid poses at his unit's makeshift headquarters, just meters away from the frontline

"During the day it can be relatively quiet but at night we have to cope with the shelling of our positions and those trying to break across our lines," explains 40-year-old Agid. He stresses that both his men and women are "highly experienced" in combat, in opposition to the majority of the peshmerga, who had not been involved in fighting until recent months.

Military routines

Although the majority of the PKK fighters are from Turkey, that is not the case with Heval Mardin. The 32-year old prefers not to disclose his birth place, although he specifies he is from "bashur ("South" in Kurdish, a term used to refer to Iraqi Kurdistan). Mardin could have easily joined the ranks of the peshmerga, but he says he had his reasons not to do so: "The PKK is not fighting for money but for an ideal of justice for all our people," explains the fighter, adding that he came to this trench after receiving training in the Qandil Mountains, the PKK stronghold, where the borders of Iraq, Iran and Turkey meet.

Others came from much further away. Like Abdullah Ocalan, the imprisoned leader of the PKK, Beritan was born in Urfa, eastern Turkey. She tells DW she joined the armed movement at 18 - she's 23 today - and that she also got military training and "ideology lessons" in Qandil. Beritan fought against Turkish security forces in the Nur Mountains, along the Aegean Sea, until her unit got the order to pull back to Qandil after the announcement of the unilateral ceasefire declared by Ocalan, in the spring of 2013.

The PKK leader's last announcement linking the future of the ceasefire to that of Kobani, the besieged Kurdish enclave in Syria, means that PKK fighters deployed today in Kirkuk could be mobilized back at any time.

"Today we are fighting here but eventually, we may receive orders to resume the fighting back in Turkey," explains Beritan sharply, adding that Ankara "has not lifted a single finger toward peace."

The belief is widespread in Kurdish areas that Turkey secretly backs Islamic extremists.

Holding off chaos?

In the meantime, the fighters stick to the rigid military routine described by Media, who comes from Diyarbakir, eastern Turkey:

"We get up at five o'clock. Breakfast is at six and the rest of the day depends on the shifts at the front. When we're not in the first line, we either get training or teach the local people who show up to learn how to operate a rifle and defend themselves," 22-year-old Media says.

Many of the PKK fighters at the Matara front are women

The conversation is interrupted by the arrival of Iraqi Border Police Commander Ahmed Fakardin. This Iraqi Kurd from Sulaymaniyah confirms to DW that Iraqi border guards, peshmerga and the PKK are "in close coordination" on the ground.

"PKK fighters make everything easier," claims Farkadin. However, he insists, "we are still in high demand of weapons and air strikes."

After inspecting the position, the officer gazes at the large number of empty water bottles at the bottom of one of the ditches. "We are soldiers, we should be more careful with our waste," says the veteran official.

But according to PKK fighter Heval Dersim, the plastic bottles are still useful even after they have been emptied.

"If the enemy tries to reach our positions at night they will surely step on them, making it much easier to detect their presence," notes this guerrilla who has just joined the always-troubled night watch.

Despite the unprecedented collaboration between Kurds, Kirkuk police commander Khabat Ali Ahmed labels the security situation "too fragile."

"We are trying to protect an area of 200 kilometers around the district, but in some spots the terrorists are less than three kilometers away from oil refineries and power plants," the security official tells DW from his desk in Kirkuk.

"Over the last years I had suggested the Kurdish Regional Government build a wall around Kirkuk," Ali Ahmeds says. "At this point, a single breach in the security line will surely bring chaos to the city."