Image copyright Jac Holmes Image caption Mr Holmes was detained in an area controlled by the Kurdistan Regional Government

Two Britons and an Irishman have been freed in Iraq after being held on their way home from fighting against so-called Islamic State (IS), the Foreign Office has said.

Jac Holmes from Bournemouth, Joe Ackerman from Halifax and Irish citizen Joshua Molloy had been detained in Kurdish-controlled northern Iraq.

Mr Holmes posted on Facebook: "Got out of jail peeps, thanks for the support."

IS controls large swathes of territory in Syria and north and west Iraq.

Mr Holmes's mother met Kurdish officials on Friday to help secure his release.

The three men were held for more than a week in a prison in the Kurdish city, Erbil.

Shortly after his release, Mr Holmes told the BBC: "It feels good to finally be out, hopefully no more trouble and we'll be on the way home soon."

Mr Ackerman updated his status on Facebook with a single word: "Free".

A Foreign Office spokeswoman said: "We are helping two British men make arrangements to leave [Iraqi] Kurdistan after they were released from custody."

Confirming the release of Mr Molloy, a former Royal Irish Regiment soldier, Ireland's Foreign Affairs Minister Charlie Flanagan said: "I welcome Joshua's release and I am pleased that he is now on his way home to join his family in Ireland."

Image copyright AFP Image caption Mr Holmes was photographed in April last year, guarding a post in northern Syria with Kurdish forces

By Emma Vardy, home affairs correspondent, BBC South

We understand the men had been waiting on the border between Syria and Iraq for several weeks trying to cross. However, the border was closed.

They made their way to another point to cross and were arrested and told they were crossing into Iraq illegally.

The border is a politically sensitive zone between Iraq and Syria. The two countries have numerous groups in conflict with one another.

Jac Holmes's mother told me it had been an anxious time as the days passed, and that she had visited Kurdish officials in London to do what she could to get Jac and the other men released.

Kurdish supporters in the UK have rallied around in support of Mr Holmes during his time fighting in Syria. He is one of a number of western volunteers fighting with the Kurds.

They call him a "hero", while British officials continue to warn strongly against travelling to any conflict zones.

The British government maintains that anyone fighting abroad could find themselves breaching UK terrorism laws.

Former IT worker Mr Holmes, who had no military experience, first entered Syria with the Kurdish People's Protection Unit, or YPG, aged 22, in January 2015.

He has previously told the BBC his interest in Syria began in 2011 and his attention gradually shifted to the struggle of the Kurds against IS.

"They [IS] are a horrendous terrorist organisation, they enslave, pillage - they think they're justified under their version of Islam," Mr Holmes told the BBC last year.

"Anyone of a sane mind can see there is nothing religious or righteous about it. I can't get over why anyone would actually join a group like Isis [IS]," he said.

During his first spell in Syria, Mr Holmes was shot through the right shoulder while fighting.

He returned to the UK in June last year, and was questioned at Heathrow airport on arrival. Some weeks later he travelled back to rejoin the conflict.

Terrorism experts say that although Britons who fight abroad may be committing offences, UK authorities are likely to take a pragmatic approach towards prosecutions, depending on whether those returning are viewed as threats to domestic security.