An Australian who travelled to Syria to fight the Islamic State (IS) group has told Four Corners he took part in active combat in what was then the group's de-facto capital of Raqqa.

Melbourne man Jamie Williams says he joined a Kurdish militia, the YPG, which is part of a US-backed coalition force dubbed the Syrian Democratic Forces (SDF).

Four Corners filmed with him in Raqqa as he showed key sites where he took part in the fight to liberate the city.

"It was pretty full on. The whole fight in Raqqa [was a] push, block by block," he said.

"Lines were constantly changing. It was hard for the YPG, the SDF forces, to keep track of where lines were."

Mr Williams' detailed account of his role may test Australia's laws against foreign fighters.

"It mattered to me because as an Australian, Da'esh [the Arabic name for IS] is a threat to Australia," he told Four Corners in Raqqa.

"The Kurds were on the frontline fighting against Da'esh on behalf of all of us. I came here to help, to do my part."

Mr Williams says he travelled to north-east Syria in April last year and returned to Australia in early January when he was questioned by Customs officers at Melbourne Airport, then formally interviewed by agents from the Australian Federal Police who he says told him he was under arrest for the duration of the interview.

He says the AFP confiscated his passport, telephone and souvenirs from Raqqa, including two IS flags and a YPG shoulder patch.

In a statement, the AFP said: "As a matter of long-standing practice, the AFP does not comment on specific security or intelligence matters."

Sorry, this video has expired Jamie Williams says this video shows the team he joined using an explosive to allow them to cross a road where an IS sniper was active.

Mission to kill Australian IS recruits

Mr Williams told Four Corners he was partly motivated to fight because other Australians, including Melbourne man Tareq Kamleh and Sydney man Khaled Sharrouf, had travelled to Syria to join IS.

"Part of the reason why I came here was to try and find and kill any Australian Da'esh that I could. Unfortunately, that hasn't happened but I would have loved to have caught some of those guys and put an end to them, definitely," he said.

Australians who have travelled to Syria to join the anti-IS campaign have been tight-lipped about their activities or maintained they only engaged in humanitarian work, which is allowed under anti-foreign fighter legislation.

However, Mr Williams says he went much further.

By his account, his team of Westerners was usually ordered to guard roads, buildings and intersections several hundred metres back from the frontline.

They risked surprise attack by IS fighters emerging from tunnels.

When they insisted on frontline duties in September, they were told to clear a building of IS fighters and move through it to the road beyond.

The mission quickly went wrong.

"We hit the road, but just as we got there, we got ambushed," he told Four Corners.

"Within five metres we took fire from about another 10 to 15 metres … One of our guys got hit in that exchange."

The team member was killed. Mr Williams and his colleagues were forced to retreat into the upper levels of a bomb-damaged apartment building.

As they tried to make a plan to escape, IS fighters probed their position, shooting on them from 10 metres away.

He was guarding the stairs against any approach from below.

"Anytime I heard any movement, any scuffling or anything underneath me, I'd pick up a grenade, get it ready, stick the rifle over, shoot down the stairs a couple of rounds, four or five rounds, pull the pin, throw the grenade down," he said.

Saved by a gunship as IS fighters closed in

Mr Williams' team of foreigners was working with local Arab fighters under the SDF umbrella.

They were in contact with their command centre, which told them a US surveillance drone had detected IS fighters converging on their position.

"We were getting the radio communications saying they were coming from this [direction], from the front, from everywhere. All of us there at this stage [were] thinking: 'Shit, how do we defend this place?'"

They were saved by airstrikes by the US-led coalition.

"There was AC-130 [gunship aircraft] gunfire, which was bombarding the whole area, one big half circle around us. There was a lot of fire for quite a while, which was comforting because you know they've got our back," he said.

"But at the same time it was worrying because they only hit targets that they can see. So knowing that they're shooting that much, that just says there was that many targets in the area for them to hit."

Sorry, this video has expired Jamie Williams says this shows him and another foreign fighter disarming a booby trapped IS mine.

'I don't think I've done anything wrong'

Mr Williams and his team have also participated in ad-hoc demining missions, helping to rid Raqqa of unexploded bombs and IS mines that have claimed hundreds of lives since IS was forced out in October last year.

While he says this is the work he's proudest of, it's his presence in Raqqa and his willingness to talk about his role in the fighting which will be most contentious.

Australia's foreign-fighter laws are broad, but they include key exceptions and definitions, which Mr Williams argues make his actions legal.

"I don't think I've done anything wrong here. I've supported the good guys in this fight … Da'esh is an enemy of the world," he said.

"The Kurds are going to be a good system. They're going to be good for this region. They need the Kurds here. They need their system. They need democracy."

The key section of the legislation makes it a crime to enter a foreign country to engage in "hostile activities".

Jamie Williams in Raqqa after the defeat of IS. ( Supplied )

Between December 2014 and the end of November last year, it was also a crime to enter Raqqa without a legitimate reason, such as humanitarian work.

However, in both cases it was not a crime to fight for, or enter the area to work for, a "government", which is defined as "the authority exercising effective governmental control".

The Kurds have administered an area of north-east Syria since late 2012. That area has grown dramatically since 2014 when the US-led coalition recruited them as the ground force to fight back against IS.

It's also a crime for an Australian to join a banned terror group.

The Kurdish Workers' Party (PKK) was banned by Australia in December, 2005 over a long-running terrorist campaign in Turkey.

The YPG is said to have links with the PKK.

However, while the ban was revised and renewed in August 2015, the YPG's activities in Syria are not included in the reasons and the US-led coalition has distinguished between the two groups, despite the angry objections of Turkey — a NATO member.

The coalition has supplied the YPG not just with air support but also intelligence, weapons and training.

When Mr Williams was stopped from travelling to Syria to join the YPG in late 2014, then charged in 2015, his alleged crime was preparing to engage in hostile activities, not preparing to join a banned group.

He argued at the time the Kurds were exercising "effective governmental control" and the Commonwealth attorney-general declined to proceed with a prosecution, without offering a detailed explanation.