RIYADH (Reuters) - A leading Qatar-based cleric declared in a religious edict, or fatwa, on Saturday that Egyptians should support ousted President Mohamed Mursi of the Muslim Brotherhood and the military should withdraw from the political scene.

Egyptian-born Youssef al-Qaradawi, one of the most prominent Sunni clerics in the Middle East, said in the fatwa posted on his website that the military's intervention to depose Mursi on Wednesday was against democracy and the constitution.

"Doctor al-Qaradawi issued a fatwa on the necessity to support the elected Egyptian president Mohamed Mursi, and to retain the constitution... and calling on al-Sisi and those with him to withdraw to preserve legitimacy and democracy," the posting said.

He said many scholars from Cairo's al-Azhar Islamic university, Egypt's pre-eminent Muslim institution, agreed with him.

Mursi was elected last summer, a year after long-time strongman Hosni Mubarak was toppled in a popular revolt with the aid of the military. The Muslim Brotherhood was banned in Egypt during Mubarak's rule.

At least 24 people were killed on Friday when supporters of Mursi protested across the country at Wednesday's coup and the subsequent detention of Muslim Brotherhood leaders.

Qaradawi, chairman of the International Federation of Muslim Scholars, has been a vociferous supporter of the revolutions that roiled Arab countries in 2011. Last month he called for a holy war in Syria against President Bashar al-Assad.

(Reporting By Angus McDowall and Amena Bakr; Editing by Ralph Boulton)