A man who posted an offensive Facebook message following the deaths of six British soldiers has been given a community order.
Azhar Ahmed, 20, of Fir Avenue, Ravensthorpe, West Yorkshire, was found guilty in September of sending a grossly offensive communication.
He said he did not think the message, which said "all soldiers should die and go to hell", was offensive.
Ahmed was also fined £300 at Huddersfield Magistrates' Court.
He will have to do 240 hours of community service over a two-year period.
Ahmed was charged after the mother of one of the soldiers read the comments and was so upset she called the police.
The six soldiers were killed by an improvised explosive device (IED) in Lashkar Gah on 6 March, in the deadliest single attack on British forces in Afghanistan since 2001.
Sgt Nigel Coupe, 33, of 1st Battalion The Duke of Lancaster's Regiment, was killed alongside Cpl Jake Hartley, 20, Pte Anthony Frampton, 20, Pte Christopher Kershaw, 19, Pte Daniel Wade, 20, and Pte Daniel Wilford, 21, all of 3rd Battalion the Yorkshire Regiment.
Ahmed's message was posted just two days later on 8 March.
Nicholas Barker, defending, said Ahmed was initially voicing "legitimate concerns" about the victims of war but went on to overstep the mark.
When he realised his 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".
'Freedom of speech'
She told Ahmed: "You posted the message in response to tributes and messages of sympathy. 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 judge.
After the hearing, a man who had a conviction for sending a menacing electronic communication on Twitter overturned, criticised Ahmed's sentence saying it was a bad day "for freedom of speech".
Paul Chambers, who posted a message saying he would blow up an airport when it closed after heavy snow, tweeted: "Glad all that fighting wasn't for nothing."
He also commented on the jailing of a man who admitted posting an offensive comment on Facebook about missing five-year-old April Jones.