CAIRO (AP) -- Egyptian soldiers and police clashed with Islamists protesting the military's ouster of the president in bloodshed that claimed at least 40 lives, officials and witnesses said, and plunged the divided country deeper into crisis with calls by the Muslim Brotherhood's political party for all-out rebellion against the army.
The carnage outside the Republican Guard building in Cairo - where toppled President Mohammed Morsi was first held last week - marked the single biggest death toll since massive protests forced Morsi's government from power and brought in an interim civilian administration.
Even before all the bodies were counted, there were conflicting accounts on how the violence began - with Morsi's backers saying it was an unprovoked attack and the military saying they came under assault first.
But the violence is almost certain to draw sharper battle lines between Morsi's Muslim Brotherhood and their opponents who claim Morsi squandered his 2012 election victory and betrayed the democratic spirit of Egypt's 2011 revolution by seeking only to bolster his and the Brotherhood's grip on the state.
Soon after the attack, however, the Al-Nour party, an ultraconservative party that had been talking to the new government about participating in the political process, announced it was withdrawing its support for the transition plan in response to the "massacre."
The military, which effectively supported the anti-Morsi movement, now may face pressures to impose stricter security measures to try to keep unrest from spilling out of control. It will also have to produce compelling evidence to support its version of events or otherwise suffer what is already shaping to be a Brotherhood media blitz to portray the military as a brutal institution with little regard for human life or democratic values.
In a move that is likely to further inflame the situation, the Freedom and Justice party, the Muslim Brotherhood's political arm, called on Egyptians to rise up against the army. Morsi has been a longtime leader of the Brotherhood.
The Freedom and Justice party also called on the international community to stop what it called the massacres in Egypt and accused the military of pushing Egypt toward civil war, warning the country was in danger of becoming a "new Syria."
Interim President Adly Mansour called for restraint and ordered a judicial inquiry into the killings. Significantly, the statement from his office echoed the military's version of events, noting that the killings followed an attempt to storm the Republican Guard's headquarters.
Pro-reform leader Mohamed ElBaradei condemned the violence and also called for an investigation.
"Peaceful transition is (the) only way," he wrote on his Twitter account.
A military spokesman said gunmen attempted to storm the building at dawn, prompting the clashes. One witness, university student Mirna el-Helbawi, also said gunmen loyal to Morsi opened fire first, including from the roof of a nearby mosque. El-Helbawi, 21, lives in an apartment overlooking the scene.
Supporters of Morsi, meanwhile, said the security forces fired on hundreds of protesters, including women and children, at a sit-in encampment outside the building as they performed early morning prayers. It was not immediately possible to reconcile the two versions.
Regardless of the reason, the escalating chaos will further complicate Egypt's relations with Washington and other Western allies, which had supported Morsi as the country's first freely elected leader and now are reassessing policies toward the military-backed group that forced him out.
At field hospitals, at least six dead bodies had been laid out on the ground, some with severe wounds, according to video from by pan-Arab broadcaster Al-Jazeera. The bodies had been draped with an Egyptian flag and pictures of Morsi. Pools of blood covered the floor and doctors struggled to deal with gaping wounds among some of the hundreds injured.
A medic from the area, Hesham Agami, said ambulances were unable to transport more than 200 wounded to hospitals because the military had blocked off the roads. Health Ministry spokesman Khaled el-Khatib said initial reports indicated at least 40 fatalities and 322 people wounded, although he gave no details on the circumstances of the bloodshed.
A Muslim Brotherhood spokesman, Mourad Ali, said army troops opened fire at dawn on the protesters outside the Republican Guard building, where Morsi was initially held but was later moved to an undisclosed Defense Ministry facility. The account was repeated by others.
"They opened fire with live ammunition and lobbed tear gas," said Al-Shaimaa Younes, who was at the sit-in. "There was panic and people started running. I saw people fall."
TV showed images provided by the military of the scene of the sit-in, where scores of protesters were pelting troops with rocks and setting tires on fire. Soldiers in riot gear and carrying shields formed lines a few meters (yards) away.
A fire raged from an apartment in a building overlooking the clashes. Images showed men throwing spears from atop nearby building rooftops. Other protesters were lobbing fire bombs at the troops. It was not clear when the footage was filmed. Security officers were showing cameras bullet casings, and troops were carrying injured colleagues.
Military spokesman Col. Ahmed Mohammed Ali said initial information indicates that gunmen affiliated with the Brotherhood tried to storm the Republican Guard building shortly after dawn, firing live ammunition and throwing firebombs from a nearby mosque and rooftops. One police officer on the scene was killed, he said.
A statement by the armed forces carried by the state news agency said "an armed terrorist group" tried to storm the building, killing one officer and seriously wounding six. The statement said the forces arrested 200 attackers, armed with guns and ammunition.
Ali, the Brotherhood spokesman, dismissed such versions, saying the protesters didn't start the confrontation. He said the military had warned protesters it will break up the sit-in.
Morsi supporters have been holding rallies and a sit-in outside the Republican Guard building since the military deposed Morsi on Wednesday. The military chief replaced Morsi with an interim president until presidential elections are held. The transition plan is backed by liberal and secular opponents of Morsi, and had been also supported by the ultraconservative Islamist Al-Nour party and both Muslim and Christian religious leaders.
Al-Nour party spokesman Nader Bakkar said on his Twitter account his party is withdrawing its support for the transition plan in response to the "massacre."
Morsi's supporters refuse to recognize the change in leadership and insist Morsi be reinstated, and have vowed to continue their sit-ins outside the Republican Guard building as well as at a nearby mosque.
Morsi's opponents are also holding rival rallies. They say the former president lost his legitimacy by mismanaging the country and not ruling democratically, leading to a mass revolt that began June 30, the first anniversary of Morsi's assumption of power.