Mahmoud Mousavi Majd was convicted of spying on Iran's armed forces, "especially the Quds Force and on the whereabouts and movements of martyr General Qasem Soleimani", judiciary spokesman Gholamhossein Esmaili said in a news conference.
Majd had been found guilty of receiving large sums of money from both the US Central Intelligence Agency and Israel's Mossad, Esmaili said.
His sentence was upheld by Iran's supreme court and would be "carried out soon," the spokesman added.
Soleimani headed the Quds Force, the foreign operations arm of Iran's Revolutionary Guards, and was killed in January in a US drone strike near Baghdad airport.
Iran retaliated by firing a volley of ballistic missiles at US troops stationed in Iraq, but US President Donald Trump opted against responding militarily.
While the attack on the western Iraqi base of Ain Al-Asad left no US soldiers dead, dozens suffered brain trauma.
Majd "will face the consequences of his actions and his masters will also witness the determination, might and intelligence reach of the Islamic republic," Esmaili said.
Iran in February handed down a similar sentence for Amir Rahimpour, another man convicted of spying for the US and conspiring to sell information on Iran's nuclear programme.
Tehran announced in December it had arrested eight people "linked to the CIA" and involved in nationwide street protests that erupted the previous month over a surprise petrol price hike.
It also said in July 2019 that it had dismantled a CIA spy ring, arresting 17 suspects between March 2018 and March 2019, and sentencing some of them to death.
Trump at the time dismissed the claim as "totally false".
Iran-US tensions have soared in recent years as Trump has pursued a campaign of "maximum pressure" against America's sworn enemy.
Since unilaterally withdrawing the US from a key nuclear deal with Tehran in May 2018, Trump has hit it with sweeping sanctions.
The two sides have appeared to come to the brink of a direct conflict multiple times in the past two years.
Yet despite the tensions and having no formal diplomatic relations since 1980, Tehran and Washington have engaged in several prisoner swaps.
The latest was on Monday when Iranian scientist Majid Taheri returned home as Iran released US Navy veteran Michael White, who had been detained in the country since his arrest in July 2018.
Taheri -- an Iranian-American who had been working at a clinic in Tampa, Florida -- had been held in the US for 16 months over violating US sanctions by sending a technical item to Iran.
Tehran had also exchanged Washington Post reporter Jason Rezaian in January 2016 for seven Iranians held in the US, on the day the nuclear agreement entered into force.
In December, Iran freed Xiyue Wang, a US academic, in exchange for scientist Massoud Soleimani.
Americans and dual nationals currently known to be held by Iran include Siamak Namazi, his father Baquer and Morad Tahbaz.
Two others -- Gholam Reza Shahini and Karan Vafadari -- have reportedly been released on bail.
Most of the Iranians held in the US are dual nationals charged with evading sanctions by either exporting goods to Iran or using the US financial system.