Erbil, Iraq - A small range of hills outside of Kirkuk has been the frontline with the Islamic State since the group fled the city last year. From a military base on top of those hills flies a Kurdish flag. But the base does not house Iraqi Kurdish peshmerga (fighters). These hills are under the control of a leftist Iranian Kurdish group, the Kurdistan Freedom Party, also known as the PAK.

Their commander-in-chief, Hussein Yazdanpana, cuts a colourful figure, his looks and thick moustache often drawing comparison with the Russian dictator Stalin. His uniform is emblazoned with the Iraqi Kurdish region's flag, and the orange-and-white insignia of his own group. He sports a battlefield radio, and a chest rig filled with ammunition clips.

Yazdanpana’s force of hundreds of fighters has managed to help turn the tide against IS in northern Iraq, gaining valuable military experience in the process and, they proudly boast, training from members of the US-led coalition in Iraq.

Once IS is defeated, Yazdanpana plans to use that experience and training against the PAK's more established enemy - Tehran. It is part of the same battle against Islamic extremism, as he sees it, and also highly personal.

"The way Daesh [IS] has been killing Yazidis [a Kurdish religious community], it was like what Iran did to the Kurds after the [1979] Iranian revolution," he said. "I was young when it happened. The regime’s forces were killing entire villages with knives and machetes.

''In Iran we will fulfill our duty. It is always Tehran that has been fighting us, killing, executing, but the world never reports on this. We now have very active, strong forces. The world can count on these forces to oppose barbaric forces in the world.''

Many Iranian Kurdish groups retreated across the border after the revolution, and up until two years ago the PAK's influence was limited to a few mountain villages near the border. Its fighters were poorly trained and their equipment outdated. That has all changed with the rise of IS.

The resurgence of Yazdanpana's group also highlights the complicated alliances that characterise the war against IS.

The US, Iran, Turkey and other regional powers are fighting the common enemy, but each uses piecemeal tactics and proxies, all with their own agendas, to gain results.

And while the US and Iran have eased longstanding tensions after forging a deal on Tehran’s nuclear programme, Washington’s support - and training for Yazdanpana's forces - opens up the prospect of long-term policy blowback.

A PAK soldier trains sights on IS positions in northern Iraq (MEE/Kim Deen) “We took advantage of every opportunity to get training, by the Americans, French, Brits - but we are always in need of more training,” he said.

Since the beginning of the counter-attacks against IS in August 2014, the PAK has fought alongside the Iraqi Kurdish government's forces and the Iraqi army.

Fighting on the frontlines has drastically changed the group's abilities. Months of operations have sharpened their skills, giving them valuable experience in direct combat, urban warfare and the use of complex weapons systems.

Yet their ultimate goal remains the same. Zohra Ramishti, a female peshmerga, puts it simply: "When we finish here, we will continue our fight for Rojhelat" - the Kurdish term for an Iranian Kurdish homeland.

As reported in MEE, the PAK has clashed at least six times with Iranian Revolutionary Guard and other forces in Iran since the spring, and a full-blown resumption of hostilities could make the already simmering war with Iran boil over.

'Sometimes we can't control them'

Falah Mustafa Bakir, the de facto foreign minister of the Kurdistan Regional Government (KRG) in Iraq, praised the Iranian Kurdish forces in his territory.

"The Iranian Kurdish peshmerga have been very loyal to us, faithful," he told Middle East Eye. "And a great fighting force."

Bakir said his government had leaned on the PAK to avoid carrying out cross-border operations, but he also conceded he did not fully control them.

"Would we have dialogue with them to prevent their cross-border activities?" said Bakir. "Well, that’s their decision."

One analyst said Iraqi Kurds' use the Iranian Kurdish militias as a way to gain leverage in their disputes with the central Iraqi government in Baghdad, which is closely allied with Tehran.

"The KRG is in dispute with Baghdad, and it needs a rhetoric against Iranian dominance in the region. The PAK helps in providing that," said Kamal Chomani of the Kurdish Policy Foundation.

"The PAK’s commander, Yazdanpana, is in close contact with the governing party, the KDP [Kurdistan Democratic Party]. Before Daesh, no one knew him, but now he is all over the media.

"He is proving to be a great media strategy for the KDP: speaking out against Daesh, Iraq and Iran at the same time."

Hussein Yazdanpana sits with officers of PAK (MEE/Kim Deen) At his base among his peshmerga, Yazdanpana repeats KDP lines on the future of territories claimed by both Iraq’s Kurds and Arabs. Discussing the future of recaptured Kirkuk and Mosul regions, he said he feared that the Iraq government was looking at the issue "from a sectarian perspective".

"We peshmerga can’t liberate these areas and then lose them," he said. "Minorities want to be protected by peshmerga, they don’t want Shia militias or the Iraqi army."

Meanwhile in Iran, media outlets have condemned the Kurdish Iraqi authorities, and the US and European advisers for providing training to the PAK.

The Associated Press news agency quoted Italian Army Captain Giulio Macari, a spokesman for the US-led coalition in Erbil, that the PAK had indeed received training “since Western advisers offered help all to Kurdish militias under the [Iraqi Kurd peshmerga] ministry's control”.

Macari said the coalition "did not choose the groups that it was training".

What happens after IS is kicked out of northern Iraq remains to be seen.

As Adnan Mufti, a former speaker of the Iraqi Kurd parliament for the Patriotic Union of Kurdistan opposition party, commented on the PAK's recent incursions into Iran: "They respected our demands well over the last decades, but sometimes we just can’t control them."

This article is available in French on Middle East Eye French edition.