A British soldier who became a hero to anti-war activists after refusing to return to Afghanistan was jailed for nine months today, despite claims that he is suffering from post-traumatic stress disorder.

"There are many soldiers in the army who have extremely unpleasant experiences, who watch friends die or suffer appalling injuries, but they have to return and do their duty," Judge Advocate Emma Peters told Lance Corporal Joe Glenton.

Glenton, 27, fled to Asia in mid-2007, before he was due to start a second tour in Afghanistan, staying abroad for two years before returning to speak at Stop the War rallies. He wrote to Gordon Brown to denounce the conflict and urge the return of all British troops.

The court martial in Colchester, Essex, sentenced him to nine months in a military jail for going absent without leave, after he pleaded guilty. He was also demoted to private. His family and supporters said Glenton, who served in Afghanistan for seven months with the Royal Logistics Corps in 2006, had been singled out because of his activism and would appeal.

Peters and a three-man panel of officers rejected mitigation pleas that Glenton simply be discharged from the army, as his psychiatric state had impaired his judgment before his planned return to Afghanistan. Peters said his decision meant either his unit returned short-handed or someone else was sent at the last minute.

Going awol, she said, "cannot be seen as a means to secure a swift exit from the services". Peters additionally cast doubt on Glenton's anti-war credentials, saying he had not raised this as an issue when he first returned to the UK last year.

After the hearing, Glenton's supporters and activists from the Stop the War group stood outside the court martial centre and said other soldiers should follow his example by deserting. "This is an outrage," said John Tipple, Glenton's legal adviser. "It is quite obvious that they are making him pay for the fact that he has spoken out."

Glenton's mother, Sue, said: "They have let Joe down and they have let his comrades down. They should hang their heads in shame." Due to automatic sentence reduction and time spent in custody he is likely to serve about five months.

Glenton was at first charged with desertion, which carries a maximum 10-year sentence, as well as five other offences connected to his anti-war activity. But these were reduced to a single charge of awol.

His legal team believe this was done to avoid a potentially embarrassing full trial at which Glenton planned to defend himself on the grounds that the entire Afghan war was illegal under international law.

The hearing heard from a consultant psychiatrist that Glenton had been diagnosed with post-traumatic stress disorder. He had not served on the front line but Glenton's base in Helmand province came under rocket and mortar attack, and his work preparing coffins for dead soldiers let him with feelings of "guilt and helplessness", Dr Lars Davidsson said.