TEHRAN, Iran - The lawyer for two American men arrested more than two years ago in Iran and convicted on charges that include espionage said Sunday he will appeal the verdict and his clients' eight-year prison sentences.

Shane Bauer and Josh Fattal were sentenced Saturday to three years for illegal entry into Iran and five years for spying for the United States. The two were arrested in July 2009 near the Iraq-Iran border along with a third American, Sarah Shourd, who was released in September on $500,000 bail and returned to the U.S. All three deny the charges, saying they were only hiking near the ill-defined border.

The Americans' Iranian lawyer, Masoud Shafiei, told The Associated Press he received the verdict of the clients on Sunday. He said his clients are innocent and that he will appeal the verdict.

"I will use entire legal capacity to defend them," he said.

Under Iranian law , a conviction on espionage can carry up to a 10-year prison sentence, while a sentence for illegal entry can run from six months to three years in jail. The terms are often significantly reduced upon appeal.

Shafiei said Bauer and Fattal were notified about the court ruling in prison on Saturday by Iranian authorities.

Iranian state TV first reported the verdict Saturday.

On Sunday, Tehran's chief prosecutor Jafari Dowlatabadi confirmed the sentences and said the Americans have 20 days to appeal. He also said that Shourd's case "is still open and will be tried in absentia."

The Americans say they mistakenly crossed into Iran when they stepped off a dirt road while hiking near a waterfall in July 2009. While other parts of Iraq remain troubled by violence, the semiautonomous Kurdish north has drawn tourists in recent years, including foreigners.

Earlier this month, Foreign Minister Ali Akbar Salehi said he hoped "the trial of the two American defendants who were detained for the crime of illegally entering Iran will finally lead to their freedom."

The gap between words by Salehi and the verdict indicates increasing rift between President Mahmoud Ahmadinejad's administration and hardline judiciary, controlled by Supreme Leader Ayatollah Ali Khamenei who has final say on all state matters.

However Ahmad Bakhshayesh , a professor of politics in Tehran Azad University believes the sentence of the American hikers is a message to the U.S., "Iran is trying to relay a tit-for-tat message to Washington that we sentence Americans as you did it against Iranian nationals in the U.S."

Over the past months, Iran has brought up the cases of several Iranians being held in U.S. custody particularly a young woman named Shahrazad Mir Gholikhan.

The mother of twin girls was sentenced in Fort Lauderdale, Florida, in 2009 to serve more than five years in federal prison for her role in a scheme to smuggle 3,500 pairs of military night-vision goggles to Iran in violation of the U.S. embargo.

Iran also has demanded an investigation into the alleged mistreatment of its own citizens in U.S. custody.

The case has added further tension to relations between the U.S. and Iran that are already strained over Tehran's disputed nuclear program. The U.S. government has appealed for the two men to be released, insisting that they have done nothing wrong.

The two countries have no direct diplomatic relations, so Washington has been relying on an interests section at the Swiss Embassy in Tehran to follow the case.