Egypt: Who holds the power?
A year after Mohammed Morsi took office as Egypt's first democratically elected president, he has been presented with an ultimatum by the military.
On 1 July, the general commander of the armed forces, General Abdul Fattah al-Sisi, warned that it would intervene if Mr Morsi did not reach an agreement within 48 hours with opposition groups to resolve the country's political crisis.
The threat has raised questions about where power lies in Egypt.
When Mr Morsi took office on 30 June 2012, he appeared to have relatively little power.
Two weeks earlier, the then ruling Supreme Council of the Armed Forces (Scaf) had issued an interim constitutional declaration amending the 30 March 2011 declaration promulgated following the overthrow of Hosni Mubarak. It restored all legislative powers to the Scaf until fresh elections were held for the dissolved lower house of parliament, the People's Assembly.
Following his inauguration, Mr Morsi moved swiftly to challenge the generals' power. On 12 August, he revoked the interim declaration issued by the Scaf in June and transferred the powers the generals had assumed to the presidency, including absolute legislative authority. Mr Morsi also made a series of personnel changes in top military positions, including forcing the retirement of the head of the armed forces and defence minister.
The response to Mr Morsi's August decrees was by and large favourable, but there was widespread anger on 22 November when, with the Islamist-dominated constituent assembly tasked with writing a new constitution was on the brink of collapse, the president issued an interim constitutional declaration granting himself far-reaching powers.
Article 2 stated that all constitutional declarations, laws and decrees issued by Mr Morsi since he took office were "final and unchallengeable by any individual or body until a new constitution has been ratified and a new parliament has been elected". Article 6 granted the president the "power to take all necessary measures and procedures" against any potential threat to the revolution, national unity or national security.
Mr Morsi portrayed his declaration as an attempt to fulfil popular demands for justice and protect the transition to a constitutional democracy. But after four days of opposition protests, the president agreed with judicial authorities to limit the scope of the decree to "acts of sovereignty".
There was further public outrage on 30 November, when the constituent assembly approved a rushed version of the draft constitution - despite a boycott by liberals, secularists and the Coptic Church - after the Supreme Constitutional Court (SCC) announced that it would rule on whether the panel should be dissolved. Mr Morsi subsequently called a referendum for 15 December.
Human rights activists said the draft provided for basic protections against arbitrary detention and torture, but failed to end military trials of civilians or to protect freedom of expression and religion.
After a "national dialogue" meeting on 8 December, Mr Morsi moved to appease his opponents by rescinding most of the 22 November decree and giving immunity from judicial scrutiny only to his "constitutional declarations".
On 9 December, the president authorised the armed forces to keep order until the referendum was held. His decree empowered soldiers to arrest and try civilians in military courts.
After the draft constitution was approved, the president and his supporters suffered a series of blows when court's ruled that the law calling fresh elections for the People's Assembly had been unconstitutional, and that the upper house of parliament, the Shura Council, had been elected on the basis of an unconstitutional law in early 2012. A third ruling limited the president's power to authorise arbitrary detentions.
On 30 June, millions of people took the streets across Egypt to demand Mr Morsi resign and allow fresh presidential elections to be held. The movement behind the protests, Tamarod (Rebel), promised a campaign of civil disobedience if the president did not step down. Mr Morsi rejected the calls, but on 1 July the military warned him to satisfy the public's demands or see the generals impose their own "road map".
A day before the 3 July deadline to reach an agreement with the opposition, Mr Morsi rejected the ultimatum and insisted he was the legitimate leader of the country. He hinted that any effort to remove him by force could plunge the nation into chaos.
The lower house, the People's Assembly, was tasked under the 30 March 2011 constitutional declaration with determining the "public policy of the state, the general plan for economic and social development, and the public budget of the state". It was also supposed to oversee the work of the executive branch.
However, on 15 June 2012 the Scaf issued a decree dissolving the People's Assembly, a day after the Supreme Constitutional Court found the law that governed Egypt's first democratic elections in more than six decades unconstitutional. The court ruled that party members should not have been allowed to contest the one third of the seats designated for independents. The Muslim Brotherhood's Freedom and Justice Party (FJP) won several 235 seats in the People's Assembly by running candidates for individual seats, as did the ultraconservative Salafist Nour party.
On 17 June, the Scaf issued an interim constitutional declaration that gave it all legislative powers until a new parliament was elected. The decree also gave the generals power to form a new constituent assembly to draft the new constitution, replacing the 100-member panel which had previously been selected by parliament. The make-up of the constituent assembly had proved controversial, with liberals, youth activists, secularists and Christians complaining that it was dominated by Islamists and did not reflect the diversity of Egyptian society. A compromise was eventually reached but then parliament was dissolved.
Nine days after taking office, President Morsi unexpectedly issued his own decree ordering the People's Assembly to reconvene, challenging the Scaf's decision to dissolve it. Mr Morsi called on the generals to respect a popular will that was expressed through free elections. He said he was not ignoring the SCC because fresh elections would be held soon after the new constitution was approved, but its judges responded by insisting their decisions were "final and not subject to appeals". In the end Mr Morsi backed down.
After the new constitution was approved in December 2012, the president promulgated a law calling elections for the People's Assembly over two months, starting in April 2013.
But on 6 March, the Cairo Administrative Court said the electoral law needed to be reviewed by the SCC. Mr Morsi said he would respect the ruling, and the SCC later found that the law did not conform to the new constitution.
The president and his supporters suffered a further blow on 2 June 2013, when the SCC ruled that the Islamist-dominated Shura Council had been elected in early 2012 on the basis of an unconstitutional electoral law. The court said the Shura Council could continue to function until the election of a new People's Assembly, but analysts said the ruling would cast a shadow on the legitimacy of any laws it passed.
The Shura Council is usually a consultative body that only gives its opinion on issues and draft laws suggested by the president and the government. However, its role was expanded in 2012 to include "full legislative authority" when the SCC disbanded the People's Assembly.
Supreme Constitutional Court
The SCC decides cases in which the constitutionality of a law or regulation is challenged.
President Morsi's constitutional declaration of November 2012 challenged the authority of the SCC, removing its power to rule on the legitimacy of any laws and decrees issued by him until a new constitution was ratified and parliamentary elections held, and also stopping it dissolving the constituent assembly and Shura Council.
On 2 December, SCC judges attempted to meet to reveal their ruling on the constituent assembly, but Islamist supporters of the president prevented them doing so. The judges subsequently announced that they were suspending the court's sessions until they could work without "psychological and physical pressures".
The SCC reconvened on 27 December, after judges accepted changes decreed by the new constitution, which saw seven of the court's most recently appointed members removed. The reduction in size effectively purged certain judges, including some who were considered Mubarak appointees and one who was known for her opposition to Islamists.
Although President Morsi regained the executive and legislative powers claimed by the Supreme Council of the Armed Forces (Scaf) in August 2012, the military is still the most powerful government entity. Many say it operates like a state within a state.
The three presidents who ruled Egypt before the revolution, along with their defence ministers, all had military backgrounds and bestowed unrivalled powers and benefits on the armed forces, particularly Hosni Mubarak.
The military has about 460,000 personnel and possesses vast land holdings and businesses. It plays a social role, providing employment and a sense of national identity to many Egyptians. But its pervasive influence has long been the subject of fierce criticism.
Estimates vary as to the size of military-owned industries - they account for around 8%-40% of Egypt's gross national product - but since their revenues are a state secret, along with the military's budget, it cannot be known for certain. The companies not only produce military hardware, but also products and services for the domestic consumer economy.
The military's influence extends far beyond its own institutions and businesses. The majority of provincial governors are retired army officers and many of the big civilian institutions and public sector corporations are run by former generals, including the three main land-developing authorities. The military is also involved in major infrastructure projects.
On 9 December, President Morsi issued a decree authorising the armed forces to protect national institutions and polling places. Analysts said it amounted to a form of martial law, because it allowed soldiers to arrest and try civilians under the military code of justice.
The army returned to barracks following the constitutional referendum, but within weeks it was forced to deploy in three cities along the Suez Canal after days of clashes between opponents and supporters of Mr Morsi left more than 50 people dead. Gen Sisi warned that the political crisis might "lead to a collapse of the state".
On 1 July, he responded to another wave of anti-government protests by threatening to impose a "road map" if the president and opposition did not resolve their differences. Mr Morsi said the warning might "cause confusion in the complicated national scene" and "threaten the social peace", while his allies believed it signalled an impending "military coup".