A man who posted a Facebook message that said "all soldiers should die and go to hell" after six British soldiers were killed in Afghanistan was today spared jail.

Azhar Ahmed, 20, admitted posting the message two days after the deaths of the Warminster-based servicemen in March.

He was charged after the mother of one of the soldiers read the comments and was so upset she called the police.

Ahmed told a trial at Huddersfield Magistrates' Court he did not think what he had written was offensive.

But the remarks were described as "derogatory, disrespectful and inflammatory" by a district judge who found him guilty of sending a grossly offensive communication.

Sergeant Nigel Coupe, 33, of 1st Battalion The Duke of Lancaster's Regiment, was killed alongside Corporal Jake Hartley, 20, Private Anthony Frampton, 20, Private Christopher Kershaw, 19, Private Daniel Wade, 20, and Private Daniel Wilford, 21, all of 3rd Battalion The Yorkshire Regiment.

Ahmed's message said: "People gassin about the deaths of Soldiers! What about the innocent familys who have been brutally killed.

"The women who have been raped. The children who have been sliced up!

"Your enemy's were the Taliban not innocent harmful familys.

"All soldiers should DIE & go to HELL! THE LOWLIFE F****N SCUM!

"Gotta problem. Go cry at your soldiers grave and wish him hell because that's where he is going."

Ahmed, of Fir Avenue, Ravensthorpe, Dewsbury, West Yorkshire, told the court at his trial last month that he deleted the post as soon as he realised what reaction it was having.

He said he replied with apologies to many people who commented on his page and when some told him they had lost relatives in Afghanistan he realised how serious it was.

But he denied the message was grossly offensive and said he thought it would just have been upsetting and caused distress.

The trial heard that the parents of one of the six soldiers who died in the incident saw the posting, which was copied around the internet.

During today's sentencing at Huddersfield Magistrates' Court, Nicholas Barker, defending Ahmed, said it was a "serious matter" but not one that warranted custody.

He said Ahmed was initially voicing "legitimate concerns" about the victims of war but went on to overstep the mark.

When he realised his latter comments were causing distress, he removed them, Mr Barker added.

District Judge Jane Goodwin said the law should not stop legitimate political opinions being strongly voiced.

But she said the test was whether what was written was "beyond the pale of what's tolerable in our society".

She ruled Ahmed's posting was not tolerable and said "I'm satisfied that the message was grossly offensive".

He was given a two-year community order with 240 hours of community service and ordered to pay £300 in costs at today's hearing.

District judge Jane Goodwin told the defendant he was "particularly foolish" and the damage caused by his comments, which could be seen by at least 600 Facebook users, was substantial.

"You posted the message in response to tributes and messages of sympathy," she said.

"You knew at the time that this was an emotive and sensitive issue.

"With freedom of speech comes responsibility. On March 8 you failed to live up to that responsibility."

The sentence was met with cries of "disgusting" from protesters in the public gallery, some of whom walked out while the district judge was speaking.

One man was detained by police while leaving the court after shouting comments at the district judge.

Outside on the court steps, around a dozen police officers watched a similarly-sized crowd of demonstrators. Many appeared to have links with far right groups.

Around an hour after he was sentenced, Ahmed left court through a side door. He was flanked by several police officers as he ran into a waiting car, which left the scene quickly.