A former Hampshire schoolboy who died fighting alongside Kurdish forces in Syria killed himself to avoid being taken hostage by Islamic State militants.

Ryan Lock, 20, died in an offensive by anti-IS forces in a bid to retake the northern city of Raaqa, considered to be the terrorist group's de facto capital.

The former chef with no previous military experience studied at Warblington School in Havant and had joined Kurdish militia after telling his family he was going on holiday to Turkey in August. 

The People's Defence Units (YPG), a Kurdish military force, told Mr Lock's family he died along with other fighters last December 21. Now it has emerged he turned the gun on himself to avoid falling captive to IS and being held as a propaganda tool.

Mr Lock's father, Jon Plater, confirmed BBC reports that it appeared he committed suicide to avoid falling captive to IS. He told the Press Association: "We did know. It is true - 100%."

YPG general command member Mihyedin Xirki described Mr Lock - who used the nom de guerre Berxwedan Givara - as a "martyr" who died "putting up a brave fight".

Xirki said in a statement: "We bless the resistance of British martyr Berxwedan Givara for the families of all martyrs and the British people."

A military ceremony attended by dozens of pro-Kurdish fighters, representatives from political parties and NGOs was held in Rojava on Tuesday.

Photographs of the ceremony showed a coffin displaying a photograph of Mr Lock and a Union flag surrounded by armed militia.

A YPG spokesman said the body of Mr Lock was handed over to the British Consulate after they had bade farewell to him, and his body is due to be repatriated to the UK "in the next few days".

In a statement, Mr Plater said: "Since we heard the devastating news of Ryan, it's been pretty tough, especially the difficulties surrounding the repatriation.

"We are grateful to the YPG for bringing him home."

The British Foreign and Commonwealth Office advises against all travel to Syria. Mr Lock is the third British man to die fighting IS with the Kurds in Syria.