Friends, family and soldiers have gathered for the funeral of an Army officer killed by a rogue member of the Afghan army on Remembrance Day.

Captain Walter Barrie was playing in a football match between British soldiers and members of the Afghan National Army (ANA) at his base in the Nad-e Ali district of Helmand province on November 11 when he was shot at close range.

The 41-year-old, from Glasgow, has been described as a "great man" by his wife, Sonia, and a "doting and amazing father" to his 15-year-old son, Callum.

Mourners gathered for the funeral at Glencorse Kirk in Penicuik, Midlothian, which was followed by a private burial.

Capt Barrie, of The Royal Scots Borderers, 1st Battalion The Royal Regiment of Scotland (1 Scots), had been mentoring a brigade of the ANA to take over security in south Afghanistan.

He had served for 25 years, including tours of Iraq, Bosnia, Kosovo, Northern Ireland and Afghanistan in 2008.

His colleagues in the Army called him a "brilliant bloke" and a "soldiers' soldier".

Rangers manager Ally McCoist was among those at the funeral of the soldier, who was an ardent fan of the Ibrox team. Among those said to be attending were the soldier's wife, his son, mother, Georgie Irvine, and stepfather, Robert Irvine.

His brother, Alan Barrie, and sister, Donna Scott, were also thought to be there.

News of the soldier's killing came after the Queen led the nation in honouring the fallen, as the country fell silent to remember its war dead. Speaking before the service, Major Norrie MacKinnon, from 1 Scots, said: "The Royal Regiment of Scotland family, and in particular 1 Scots, will acknowledge the life of a very special officer.

"Every member of my battalion currently deployed in Afghanistan will want to be at Glencorse Parish Kirk to say their farewell and salute a true Scottish hero.

"But we also know that Walter would want nothing more than for his comrades to remain steadfast and at their post doing the job and the mission they were sent to do. Walter was a true professional, leaving a benchmark for us all, a standard to which we all aspire."

The coffin – bearing a Union flag, Capt Barrie's officer's sword, head-dress, medals, Sam Browne belt and a poppy wreath – was carried into the service to the sound of a lone piper.

A poignant floral tribute spelled out the word "Dad". The congregation heard a tribute from the officer's son, Callum.

He said: "If I was to describe my dad in three words, I would say he was caring, funny and kind. One thing I will always remember is that he'd give anything a try and would always do it with a smile on his face.

"He always treated everyone he met with respect and usually managed to have a laugh too."

An Army spokeswoman said an estimated 900 to 1000 people attended the funeral.

A statement on behalf of Capt Barrie's wife Sonia was read out, before the coffin was carried out of the service to the sound of the Tina Turner song Simply the Best. The statement said: "Walter Reid Barrie was simply the best. Love and miss you forever. Sonia."