Another official quoted on Iran's state TV website said Ashtari "relayed sensitive information on military, defence and research centres" to Israel's Mossad spy agency.
An Iranian official said that Ashtari can appeal his sentence.
"This is an initial verdict and should receive final approval. The defendant can appeal," an unnamed intelligence official was quoted as saying.
"He fell into the trap of the foreign intelligence services. They took advantage of his situation. They asked him to co-operate and he co-operated," source said.
The verdict comes amid escalating tensions between Iran and Israel, over Tehran's nuclear energy programme.
Israel, backed by the US, says Iran is covertly developing atomic weapons while Tehran insists that its nuclear programme is for civilian purposes.
According to Ashtari's "confession", published in full by Fars, he was a salesman of telecoms equipment used to help the Israeli intelligence service Mossad access secret information from Iranian officials.
Mossad gave him $50,000 to buy internet cables and satellite phones and then sell them on to "special customers" in the hope of enabling Israel to spy on their communications, Ashtari said.
'Failures are irreversible'
The intelligence official quoted by the Iranian Mehr news agency said Ashtari had contacts with the Iranian Atomic Energy Organisation and military bodies.
"His action was definitely one of treason because some of our research projects have failed because of the use of this equipment," the official said.
"In some cases failures are irreversible and big."
The source did not give details about which projects had been affected. State television broadcast pictures of Ashtari at his trial showing the satellite phone, laptop and other equipment allegedly used in his work.
His handlers "introduced themselves as Jacques, Charles and Tony," Ashtari said.
"I had meetings in Thailand, Turkey and Switzerland with them. They gave me some equipment including a laptop through which I could send encrypted emails," he said.
They wanted "me to sell these terminals in Iran to my special customers so they could hack into this equipment.
"I am not sure what they intended to do as before I sold these to my customers I was arrested," he added.
Trials against Iranians accused of spying for Israel are a rarity, despite the enmity between the two states.