CAIRO (Reuters) - An Egyptian court on Saturday sentenced ousted president Mohammed Mursi of the Muslim Brotherhood to 25 years in prison in a final ruling over a case accusing him of spying for Qatar, judicial sources said.

Mursi, democratically elected after Egypt's 2011 revolution, was overthrown in mid-2013 by then-general Abdel Fattah al-Sisi, now the president, following mass protests against his rule. He was immediately arrested.

Egypt's Court of Cassation reduced Mursi's sentence in the Qatar case to 25 years in its final ruling, from an original 40 years.

Mursi is already serving a 20-year sentence after being convicted for the killing of protesters during demonstrations in 2012.

Since toppling Mursi, Sisi has clamped down on dissent. Mass trials have been held for thousands of Muslim Brotherhood supporters, and hundreds have received death sentences or lengthy prison terms.

In 2014, Egypt charged Mursi and nine others with endangering national security by leaking state secrets and sensitive documents to Qatar. Egypt's relations with Doha were already troubled by Qatar's backing of Mursi.

Egypt is one of four Arab nations in a Saudi-led bloc that cut relations with the Gulf state on June 5, accusing it of backing militant groups and cooperating with their arch-foe Iran, allegations Doha denies.

(Reporting by Haitham Ahmed; writing by Patrick Markey; editing by Clelia Oziel)