Mohammad Heidari, accused of passing security-related information and secrets to Israeli Mossad agents in exchange for money, and Kourosh Ahmadi, accused of gathering information for the U.S. Central Intelligence Agency, were hanged at dawn, it said.
The sentence for their execution was handed down by Tehran's Revolutionary Court and confirmed by the country's Supreme Court. The report did not say when the pair were arrested nor when their trial took place.
Iran has in the past said it had successfully detected and dismantled spy networks operating inside the country. It has blamed the assassinations of scientists associated with its disputed nuclear programme on Western spy agencies, especially Mossad.
The executions were held as Iran prepares for a June 14 presidential election.
Iran's electoral watchdog said on Monday it would bar physically feeble candidates from running for president, in an apparent hint that it could disqualify 78-year-old former President Akbar Hashemi Rafsanjani from the race.
Rafsanjani, if he is allowed to run, would be a significant challenge to conservative hardliners who are ultra-loyal to Supreme Leader Ayatollah Ali Khamenei and who otherwise dominate the field for the presidential election.
The wily, pragmatic cleric, who has often been close to the heart of power since Iran's 1979 Islamic Revolution, shook up the election contest earlier this month when he joined the race.
But the Guardian Council, a conservative body of clerics and jurists that vets all candidates, may disqualify him, along with Esfandiar Rahim Mashaie, a close ally of President Mahmoud Ahmadinejad, who also registered to run at the last moment.
"If an individual who wants to take up a high post can only perform a few hours of work each day, naturally that person cannot be confirmed," Guardian Council spokesman Abbas Ali Kadkhodai said on Monday, according to the ISNA news agency.
Kadkhodai did not name Rafsanjani. The council is due to present a final list of approved candidates on Tuesday to the Interior Ministry, which then has two days to announce it.
Hardline legislators demanded last week that Rafsanjani and Mashaie be banned from running.
Rafsanjani earned hardliners' ire for criticising the crackdown on opposition protests after Ahmadinejad was re-elected in 2009 in a vote that reformists said was rigged.
Conservatives are suspicious of Mashaie, saying he holds an unorthodox view of Islam and seeks to sideline clerical rule.
Lawmaker Ali Motahari, who is close to Rafsanjani, told reporters on Monday that a rejection of Rafsanjani's candidacy would put the very principles of the state under question, "because Hashemi (Rafsanjani) had the biggest role in the Islamic revolution", according to the ILNA news agency.
He derided the idea that Rafsanjani was too old, saying: "How do they know whether Hashemi can run the country or not?"
Motahari also suggested that Khamenei could step in to push the Guardian Council to approve Rafsanjani's candidacy if it is initially rejected. The body re-qualified two reformist presidential candidates in 2005 after Khamenei intervened.
Parliament proposed age restrictions for presidential candidates last year, but dropped the measure after opposition from the Guardian Council.
Many Iranians would view Rafsanjani's disqualification on the basis of age as a political pretext - and it might look awkward for Khamenei, who reinstated Rafsanjani as head of the Expediency Council, an advisory body, in 2012.
"It is hard to fathom a justification for Rafsanjani's disqualification," said Farideh Farhi, an Iran analyst at the University of Hawaii. "His disqualification on the basis of not being sufficiently committed to the Leader will also challenge the Leader's judgment." (Additional reporting by Marcus George; Editing by Alistair Lyon)