Two US hikers accused of spying and illegally entering Iran have been jailed for eight years by a court in Tehran, reports say. Iranian state TV's website said Shane Bauer and Josh Fattal each received three years for illegally entering Iran and five years for spying. The two men deny the charges, saying they unknowingly crossed into the country while hiking in July 2009. Their fellow hiker Sarah Shourd was released on bail last September. She flew back to the US and did not return to face trial, saying in May she had suffered from post-traumatic stress and would find a return "too traumatic". The trial began in February 2011 and Mr Bauer and Mr Fattal pleaded not guilty. Ms Shourd pleaded not guilty in absentia. The trial ended on 31 July, on the second anniversary of their arrest. "In connection with illegal entry into Iranian territory, each was given three years in jail and in connection with the charge of co-operating with American intelligence service, each was given five years in jail," the website reported, quoting an informed judiciary source. The report said "the case of Sarah Shourd, who has been freed on bail, is still open," AFP news agency says. During the trial, prosecutors said they had evidence the three were connected to US intelligence agencies. The trio said they had been hiking in Iraqi Kurdistan and did not intentionally stray over the border with Iran, where they were arrested by soldiers. Ms Shourd said they had visited the tourist village of Ahmed Awa, and hiked along a trail local residents had recommended.