Aljazeera's correspondent in Sanaa said the criminal court, which deals with terrorism cases, awarded the death penalty to Ali Yahya on Sunday for supporting what the Yemeni authorities described as the "rebellion" that was led by the Zaidi Shia cleric, Shaikh Badr al-Din al-Huthi, and his son in the north of Yemen.
Yahya was accused of contacting foreign countries.
Furthermore, the court handed out an eight-year prison sentence to Yahya's friend, Muhammad Miftah, after convicting him of incitement of violence and sectarianism.
Reuters said the court accused the duo of wanting to overthrow the Arab country's republican system by supporting the rebellion launched last year by supporters of al-Huthi.
The judge evicted the defendants, who gave sermons in Sanaa mosques, before announcing the verdict because they were loudly reciting the Quran.
Their lawyers said they would appeal.
It was unclear for which foreign country the men had been found guilty of spying, though prosecutors had mentioned Iran in the early stages of the trial, which lasted five months.
Yemen says the northern rebels want to install clerical rule and preach violence against the US and Israel. The group is not linked to al-Qaida.