Sheikh Ali Salman, who headed the now-outlawed Al-Wefaq movement, had been acquitted by the high criminal court in June, a verdict the public prosecution appealed.
The latest ruling on Sunday can also be appealed.
Bahrain, along with Saudi Arabia and the United Arab Emirates, severed all ties with Qatar in 2017, banning their citizens from travel to or communication with the emirate over what they say are Doha's ties to both Iran and radical Islamist groups.
Salman is currently serving a four-year sentence in a separate case -- "inciting hatred" in the kingdom, which has seen mainly Shiite protests against the Sunni monarchy since 2011.
In November, Salman and two other members of Al-Wefaq were charged with working for Qatari intelligence with the aim of overthrowing the Bahraini government.
King Hamad has announced parliamentary elections on November 24 in Bahrain. Members of dissolved opposition parties, including Al-Wefaq and the secular Al-Waad group, are banned from running.
The Sunni-ruled Gulf state has been hit by waves of unrest since 2011, when security forces crushed Shiite-led protests demanding a constitutional monarchy and an elected prime minister.
Opposition movements have been outlawed and hundreds of dissidents have been imprisoned -- with many stripped of their nationality.
Bahrain last year ratified a constitutional amendment granting military courts the authority to try civilians charged with terrorism, a term that is loosely defined by the Bahraini penal code.
In June, the kingdom amended its law on political rights, prohibiting "leaders and members of political associations dissolved for violating the kingdom's constitution or its laws" from running in legislative elections.
Bahrain, a key ally of the United States and home to the US Fifth Fleet, accuses Shiite Iran of provoking unrest in the kingdom. Iran denies the allegations.
The United Nations and rights groups including Amnesty International and Human Rights Watch have criticised the Bahraini monarchy over its treatment of protesters.
Amnesty and HRW categorise Salman and other jailed opposition leaders prisoners of conscience.