Mr. Lock, 20, from Chichester, had joined up with the People's Protection Units (YPG), which was fighting Daesh in northern Syria.
In July, Daesh confirmed its leader, Abu Bakr al-Baghdadi, had been killed by a Russian airstrike in Raqqa in June.
The coroner, David Horsley, recorded a narrative verdict and said Mr. Lock suffered a leg wound which made him vulnerable to capture and shot himself to avoid failing into the hands of a "cruel and ruthless" enemy.
Ryan Lock – Rest easy warrior & enjoy the majestic halls of Valhalla https://t.co/WkcXWKKCl7 pic.twitter.com/U3e5rG6Qnq
— Belfast Child (@bfchild66) August 2, 2017
Mr. Lock, a chef who had never had any military training, traveled to Turkey in August 2016, and told his family he was on holiday.
He then revealed he was not backpacking through Turkey, but had joined up with the YPG, initially as a chef and medic.
His mother, Catherine, said she "absolutely panicked" and was shocked.
He kept in touch with his family via Facebook Messenger, but never admitted he was actually in combat.
"Deep down, there were things setting off alarm bells, but I wasn't getting the answers," she said.
She said she told him: "I'm proud of you, but for God's sake come home safely."
Mrs. Lock told the inquest her son was obviously troubled by the situation in Syria before he left.
RIP Ryan lock, an incredibly brave young man who gave his life fighting evil, local boy who really is one of our own.
— Steve Claridge (@SteveClaridge) 2 August 2017
"But it wasn't something he would constantly comment on," she told the inquest.
The family lost contact with him in December and his father Jon Plater then stumbled across horrific images of a Daesh fighter standing over his body near Raqqa.
Reports at the time said five YPG fighters came under siege by Daesh in the village of Ja'bar, and showed "considerable resistance" before they were killed.
"During a battle with Islamic State, Ryan gave his life fighting for a cause to which he had dedicated his all. He was a very brave young man. He died doing something quite clearly he believed passionately in. I think that has to be the memorial for Ryan. We've lost a heroic young man," said Mr. Horsley.
In January, Mr. Lock's body was recovered and brought back to Britain, via Iraq.
Pathologist Dr. Basil Purdue said the cause of death was a single gunshot wound to the head.
After it overran large parts of northern Syria and Iraq in 2014 Daesh, began the practice of beheading captives, especially foreigners.
The videos of the beheadings were often uploaded and shared on Daesh websites.
Among those who were beheaded were US journalist James Foley, who had been captured in 2012, Israeli journalist Steven Sotloff, British aid workers David Haines and Alan Henning, and Japanese military contractors Kenji Goto and Haruna Yukawa.
In the last few months, a US-backed coalition has surrounded Raqqa, which is the Daesh de facto capital, and is now engaged in street fighting.
Since the beginning of the operation for the liberation of Raqqa, nine districts of the city have been released from Daesh and the Syrian Democratic Forces (SDF) now control half of the city.
The largest element of the SDF is the YPG, which Mr. Lock had served in.