* Cairo clash leaves 51 dead, deepens country's crisis
* Islamist protesters say army fired on them during prayers
* Army says "terrorist group" tried to storm building
* U.S. urges "maximum restraint" from Egypt military
By Alexander Dziadosz and Shadia Nasralla
CAIRO, July 8 At least 51 people were killed on Monday when the Egyptian army opened fire on supporters of ousted president Mohamed Mursi, in the deadliest incident since the elected Islamist leader was toppled by the military five days ago.
Protesters said shooting started as they performed morning prayers outside the Cairo barracks where Mursi is believed to be held.
But military spokesman Ahmed Ali said that at 4 a.m. (0200 GMT) armed men attacked troops in the area around the Republican Guard compound in the northeast of the city.
"The armed forces always deal with issues very wisely, but there is certainly also a limit to patience," the uniformed Ali told a news conference, at which he presented what he said was video evidence, some of it apparently taken from a helicopter.
Emergency services said 435 people were wounded.
Mursi's Muslim Brotherhood urged people to rise up against the army, which they accuse of a coup to topple the president. The movement's leaders are calling for peaceful resistance, but the risk remains of fringe elements pursuing a violent agenda.
At a hospital near the Rabaa Adawiya mosque where Islamists have camped out since Mursi was ousted, rooms were crammed with people wounded in the violence, sheets were stained with blood and medics rushed to attend to those hurt.
"They shot us with teargas, birdshot, rubber bullets - everything. Then they used live bullets," said Abdelaziz Abdel Shakua, a bearded 30-year-old who was wounded in his right leg.
Bloody scenes from Cairo, three days after clashes between pro- and anti-Mursi protesters across the country claimed 35 lives, have alarmed Egypt's allies, including Israel, with which it has had a U.S.-backed peace treaty since 1979.
Key donor the United States, still refraining from calling the military intervention a "coup" - a label that would trigger legal obstacles to continuing aid payments - called on Egypt's army to exercise "maximum restraint" in dealing with protesters and on those demonstrating to do so peacefully.
The White House said aid was not about to halt aid to Egypt.
The Egyptian military, recipient of $1.3 billion a year from Washington, has insisted that the overthrow was not a coup, and that it was enforcing the "will of the people" after millions took to the streets on June 30 to call for Mursi's resignation.
The turmoil leaves the Arab world's largest nation of 84 million people in a perilous state, with the risk of further enmity between people on either side of the political divide while an economic crisis deepens.
SHOTS DURING PRAYERS
As an immediate consequence of the clash, the ultra-conservative Islamist Nour party, which initially backed the military intervention, said it was withdrawing from talks to form an interim government for the transition to new elections.
A spokesman for the interim presidency, Ahmed Elmoslmany, said work on forming the government would go on, though Nour's withdrawal could seriously undermine efforts at reconciling rival factions.
A Reuters journalist at the scene saw first aid helpers attempting mouth-to-mouth resuscitation on a dying man.
Al Jazeera's Egypt channel showed footage from inside a makeshift clinic near the scene of the violence, where Mursi supporters attempted to treat bloodied men.
Seven dead bodies were lined up in a row, covered in blankets and an Egyptian flag. A man placed a portrait of Mursi on one of the corpses.
Film broadcast by Egyptian state TV showed Mursi supporters throwing rocks at soldiers in riot gear on one of the main roads leading to Cairo airport.
Young men, some carrying sticks, crouched behind a building, emerging to throw petrol bombs before retreating again.
Footage posted on YouTube on Monday showed a man on a rooftop wearing what appeared to be a military helmet opening fire with a rifle five times, apparently in the direction of a crowd in the street below.
In the clip, which could not be independently verified, two bloodied men were shown carried away unconscious. The military was not immediately available for comment on the images.
State-run television showed soldiers carrying a wounded comrade along a rock-strewn road, and news footage showed a handful of men who looked like protesters firing crude handguns.
The rest of the city was for the most part calm, though armoured military vehicles closed bridges over the Nile to traffic following the violence.
Talks on forming a new government were already in trouble before Monday's shooting, after the Nour Party rejected two liberal-minded candidates for prime minister proposed by interim head of state Adli Mansour, the top constitutional court judge.
Nour, Egypt's second biggest Islamist party, which is vital to give the new authorities a veneer of Islamist backing, said it had withdrawn from the negotiations in protest at what it called the "massacre at the Republican Guard (compound)".
"The party decided the complete withdrawal from political participation in what is known as the road map," it said.
The military can ill afford a lengthy political vacuum at a time of violent upheaval and economic stagnation.
The violence has shocked Egyptians, growing tired of the turbulence that began two-and-a-half years ago with the overthrow of autocrat Hosni Mubarak in a popular uprising.
In one of the most disturbing scenes of the last week, video footage circulated on social and state media of what appeared to be Mursi supporters throwing two youths from a concrete tower on to a roof in the port city of Alexandria.
The images, stills from which were published on the front page of the state-run Al-Akhbar newspaper on Sunday, could not be independently verified.
On Sunday, huge crowds numbering hundreds of thousands gathered in different parts of Cairo and were peaceful, but nonetheless a reminder of the risks of further instability.
For many Islamists, the overthrow of Egypt's first freely elected president was a bitter reversal that raised fears of a return to the suppression they endured for decades under autocratic rulers like Mubarak.
On the other side of the political divide, millions of Egyptians were happy to see the back of a leader they believed was orchestrating a creeping Islamist takeover of the state - a charge the Brotherhood has vehemently denied.
EU foreign policy chief Catherine Ashton said she deplored the loss of life: "All those who claim legitimacy must act in a responsible way for the good of the country and avoid any provocation or escalation of violence," she said in a statement.
Washington's decision not to condemn the military takeover or call it a coup has prompted suspicion within the Brotherhood that it tacitly supports the overthrow.
Were the United States to decide that Mursi was toppled in a coup, it would be required by law to cut off annual assistance of $1.5 billion, most of which goes to the Egyptian military.
But White House spokesman Jay Carney said that the United States would not immediately cut off aid to Egypt.
Egypt can ill afford to lose foreign aid. The country appears headed for a looming funding crunch unless it can quickly access money from overseas. The local currency has lost 11 percent of its value since late last year.
On Monday, British energy firms BG Group and BP said they had pulled 160 expatriate staff out of Egypt due to spreading unrest, although operations and production were not expected to be affected.
Egypt's share index lost 3.6 percent on Monday.