Shane Bauer and Joshua Fattal, both 28, have 20 days to appeal the prison terms, the Tehran Times reported.
Bauer, Fattal and Sarah Shourd, all graduates of the University of California at Berkeley, were arrested more than two years ago on the border between Iraq and Iran. They said they had been hiking and that Iranian border guards detained them in Iraqi territory, but Iran said they were working for the CIA.
Shourd was freed on bail last year and is now in the United States.
Bauer and Fattal were tried by the Revolutionary Court, which has been accused of paying more attention to politics than justice, the Los Angeles Times reported. Massoud Shafei, their lawyer, said he has been given no official notification of the sentences.
Shafei had said he hoped the men would be released as a goodwill gesture during Ramadan. The Muslim holy month ends this year on Aug. 29.