CAIRO — A court ruling Monday raised the possibility of jailed ex-president Hosni Mubarak walking free soon, a move that would fuel the unrest roiling the country after the autocratic leader's successor was removed in a military coup.

The development happened on a chaotic day of bloodshed that ended with the military's detention of the supreme leader of the Muslim Brotherhood, the Islamist group from which ousted president Mohammed Morsi hails. Underscoring the growing anger over Morsi's ouster, suspected Islamic militants ambushed two minibuses carrying off-duty policemen in Egypt's Sinai Peninsula, forcing the men to lie on the sand and shooting 25 of them dead.

"They were marked in advance by the attackers," said Ashraf Abdullah, who heads the police branch the victims belonged to. He said the assailants checked the IDs of the men, who were not in uniform, to ensure they were policemen before opening fire.

The brazen daylight attack raised fears that the strategic desert region bordering Israel and the Gaza Strip could be plunged into a full-fledged insurgency.

Early on Tuesday, Brotherhood leader Mohammed Badie was captured in an apartment in the eastern Cairo district of Nasr City, according to security officials and state television. That's where Morsi's supporters held a six-week sit-in protest that was cleared by security forces last Wednesday.

The private ONTV network showed footage of a man the network said was Badie after his arrest. In the footage, a somber looking Badie in an off-white Arab robe, or galabiyah, sits motionless on a sofa as a man in civilian clothes and carrying an assault rifle stands nearby.

Badie and his powerful deputy Khairat el-Shater, who is in custody, go on trial later this month for their alleged role in the killing of eight protesters outside the Brotherhood's Cairo headquarters in June. His arrest is a serious blow to the group at a time when authorities are cracking down on its leaders and mid-ranking officials, detaining scores of them across the country.

The officials spoke on condition of anonymity because they were not authorized to speak to the media.

The 25 slain police officers were given a funeral with full military honors presided over by Interior Minister Mohammed Ibrahim, who is in charge of the police, and the army's chief of staff, Gen. Sedki Sobhi.

In a show of solidarity, the men's coffins, draped in red, white and black Egyptian flags, were jointly carried by army soldiers and policemen, and interim President Adly Mansour declared a nationwide state of mourning to mark their deaths.

Despite the violence, Cairo, a bustling metropolis of some 18 million people, began to regain a sense of normalcy although the capital remained under a state of emergency and a dusk-to-dawn curfew.

Daytime traffic was back to its normal congested levels and stores were open. Government employees returned to work and the Central Bank ordered banks, which were operating on a reduced 9 a.m.-noon schedule, to remain open for an additional hour on Tuesday. A handful of protests erupted in various parts of the city, but they were small and led to no violence.

Mubarak, 85, has been in detention since April 2011, two months after he was ousted in a revolution against his rule.

He was found guilty and sentenced to life in prison last year for failing to stop the killing of some 900 protesters in the 18-day uprising. His sentence was overturned on appeal and he is now being retried, along with his security chief and six top police commanders.

Two judicial officials said Mubarak could walk free this week or next after a criminal court on Monday ordered his release in a corruption case in which he and his two sons were accused of embezzling funds for the maintenance of presidential palaces. His sons were ordered kept in custody.

Monday's ruling, along with the fact that Mubarak had previously been ordered released in the killings of the protesters opened the possibility of freedom for the former president, the officials said, speaking on condition of anonymity because they were not authorized to speak to the media.

There will no longer be any grounds to hold him if a court accepts a petition by his lawyer requesting his release in a third case later this week or next.

Many analysts, however, expressed skepticism, saying the political cost of freeing the former leader, who was widely hated for widespread abuses and repression during his 29 years in power, could keep him in jail.

Leading rights campaigner Nasser Amin and rights lawyer Hoda Nasrallah said they did not expect Mubarak to be released, citing the country's delicate political and security situation as well as past incidents when authorities brought up new allegations to prevent his release.

Amin complained that Egypt's penal law, which dates to the 1930s, has no adequate provisions to allow the conviction of perpetrators of crimes like ordering or failing to prevent the killing of protesters. Already, the overwhelming majority of court cases brought against policemen charged with killing protesters have ended in acquittals or suspended sentences.

"His release or detention will be a decision that weighs political and security conditions in the country," said Nasrallah.

Freeing Mubarak during one of the worst bouts of turmoil since his ouster would be a huge risk for the military-backed government. It could lend credibility to allegations that the mass protests that preceded the July 3 coup that toppled Egypt's first democratically elected leader were the work of Mubarak-era figures searching for a way to reinstate the former regime.

Last week, the military raided two protest camps of Morsi's supporters in Cairo, killing hundreds of people and triggering a wave of violence that has left at least 1,000 people dead.

Human Rights Watch, in a report released Monday, accused Egyptian security forces of using excessive force when they moved to clear the larger of the two camps. The New York-based group said the assault amounted to the "most serious incident of mass unlawful killings in modern Egyptian history."

It called on authorities to reverse a recent decision authorizing the use of deadly force by security forces when they come under attack or when key government facilities are assaulted.

The Sinai Peninsula has long been wracked by violence by al-Qaida-linked fighters, some who consider Morsi's Brotherhood to be too moderate, and tribesmen who have used the area for smuggling and other criminal activity.

However, Islamic militancy has been on the rise in the area, with almost daily attacks targeting security forces since Morsi's ouster.

Monday's attack targeting the police officers took place near the border town of Rafah in northern Sinai. A few hours later, militants shot to death a senior police officer as he stood guard outside a bank in el-Arish, another city in the largely lawless area, security officials said.

There was no immediate claim of responsibility for either attack. The United States condemned the slaying of the police officers and repeated its commitment to help Egypt combat terrorism in Sinai. U.N. Secretary-General Ban Ki-moon also denounced the attack.

"The Sinai Peninsula remains an area of concern, and the current situation in Egypt has not improved the situation," State Department spokeswoman Jen Psaki told reporters in Washington. "The United States continues to support Egypt's ongoing efforts against terrorism and growing lawlessness in the Sinai, and we continue to cooperate with Egypt in these efforts."

The attacks came a day after security forces killed 36 detainees during a riot on a prison-bound truck convoy north of Cairo. The killings came as police fired tear gas to free a guard who was trapped in the melee, security officials said.

On Monday, the government ordered an inquiry into the deaths, which it blamed on armed men allegedly trying to help the 600 Muslim Brotherhood detainees escape. It gave no details.

The Brotherhood blamed military chief, Gen. Abdel-Fattah el-Sissi, and the interior minister for Sunday's killings. The group also called for an international inquiry into the deaths.

The United States said it was troubled by the "suspicious deaths" of the prisoners.

"We call on all Egypt's leaders and the international community to condemn such attacks without equivocation," said Psaki, the State Department spokeswoman.

Amnesty International demanded a "full, impartial and effective" probe into the events.

Morsi has been held in an undisclosed location since his ouster. On Monday, prosecutors ordered his detention for 15 days in connection with allegations that he conspired to kill and torture protesters during mass demonstrations by the opposition outside his presidential palace in December 2012.

___

Associated Press writer Deb Riechmann contributed to this report from Washington.

Earlier on HuffPost:

Loading Slideshow...
  • Egyptian army soldiers take their positions on top and next to their armored vehicles while guarding an entrance to Tahrir square, in Cairo, Egypt, Friday, Aug. 16, 2013. (AP Photo/Hassan Ammar)

  • Egyptian government employees clean up outside the Rabaah al-Adawiya mosque, in the center of the largest protest camp of supporters of ousted President Mohammed Morsi, that was cleared by security forces, in the district of Nasr City, Cairo, Egypt, Friday, Aug. 16, 2013. (AP Photo/Hassan Ammar)

  • Egyptian army soldiers take their positions on top and next to their armored vehicles while guarding an entrance to Tahrir square, in Cairo, Egypt, Friday, Aug. 16, 2013. (AP Photo/Hassan Ammar)

  • Supporters of ousted Egyptian President Mohammed Morsi, one holding a newspaper with images from Wednesday's crackdown, march towards downtown Cairo from the Mohandeseen district of Cairo, Egypt, Friday, Aug, 16, 2013. (AP Photo/Thomas Hartwell)

  • An Egyptian man collects and removes items from what is left of burned cars outside the Rabaah al-Adawiya mosque, in the center of the largest protest camp that was cleared by security forces, in the district of Nasr City, Cairo, Egypt, Friday, Aug. 16, 2013. (AP Photo/Hassan Ammar)

  • Egyptians collect and remove items from what is left of damaged tents outside the Rabaah al-Adawiya mosque, where supporters of Egypt's ousted President Mohammed Morsi had a protest camp in Nasr City, Cairo, Egypt, Friday, Aug. 16, 2013. (AP Photo/Hassan Ammar)

  • A trampled poster of Egypt's ousted President Mohammed Morsi is seen on the ground outside the Rabaah al-Adawiya mosque, where supporters of Morsi had a protest camp in Nasr City, Cairo, Egypt, Friday, Aug. 16, 2013. (AP Photo/Hassan Ammar)

  • Supporters of ousted Egyptian President Mohammed Morsi cross the Nile as they march towards downtown Cairo from the Mohandeseen neighborhood of Cairo, Egypt, Friday, Aug. 16, 2013. (AP Photo/Thomas Hartwell)

  • Egyptian Army soldiers take their positions on top of their armored vehicles while guarding an entrance to Tahrir Square, in Cairo, Egypt, Friday, Aug. 16, 2013. (AP Photo/Hassan Ammar)

  • An Egyptian collects items from what is left of damaged tents outside the Rabaah al-Adawiya mosque, where supporters of Egypt's ousted President Mohammed Morsi had a protest camp in Nasr City, Cairo, Egypt, Friday, Aug. 16, 2013. (AP Photo/Hassan Ammar)

  • Abandoned shoes and a tea glass, belonging to supporters of ousted Egyptian President Mohammed Morsi, remain on a wall outside the Rabaah al-Adawiya mosque, in the center of the largest protest camp of supporters of ousted President Mohammed Morsi, that was cleared by security forces, in the district of Nasr City, Cairo, Egypt, Friday, Aug. 16, 2013. (AP Photo/Hassan Ammar)

  • Egyptian army soldiers take positions on top of their armored vehicles while guarding a street that leads to Rabaah al-Adawiya mosque, at the site of the largest protest camp of supporters of ousted President Mohammed Morsi, that was cleared by security forces, in the district of Nasr City, Cairo, Egypt, Friday, Aug. 16, 2013. (AP Photo/Hassan Ammar)

  • Egyptian Army soldiers stand guard outside the Rabaah al-Adawiya mosque, in the center of the largest protest camp of supporters of ousted President Mohammed Morsi, that was cleared by security forces, in the district of Nasr City, Cairo, Egypt, Friday, Aug. 16, 2013. (AP Photo/Hassan Ammar)

  • Egyptian government employees clean up outside the Rabaah al-Adawiya mosque, at the site of the largest protest camp of supporters of ousted President Mohammed Morsi, that was cleared by security forces, in the district of Nasr City, Cairo, Egypt, Friday, Aug. 16, 2013. (AP Photo/Hassan Ammar)

  • Supporters of Egypt's ousted President Mohammed Morsi carry coffins, covered with national flags, of their colleagues who were killed during Wednesday' clashes in Amr Ibn Al-As mosque before a funeral prayers in Cairo, Egypt, Friday, Aug. 16, 2013. (AP Photo/Amr Nabil)

  • An Egyptian Army soldier takes his position on top of an armored vehicle while guarding an entrance to Tahrir Square, in Cairo, Egypt, Friday, Aug. 16, 2013. (AP Photo/Hassan Ammar)

  • An Egyptian walks in front of an army armored vehicle that guards an entrance of Tahrir Square, in Cairo, Egypt, Friday, Aug. 16, 2013. (AP Photo/Hassan Ammar)

  • An Egyptian man walks through debris from what is left of burned vehicles outside the Rabaah al-Adawiya mosque, where supporters of Egypt's ousted President Mohammed Morsi had a protest camp, that was cleared by security forces, in the district of Nasr City, Cairo, Egypt, Friday, Aug. 16, 2013. (AP Photo/Hassan Ammar)

  • Supporters of ousted Egyptian President Mohammed Morsi, one holding a picture of Morsi, march towards downtown Cairo from the Mohandeseen neighborhood of Cairo, Egypt, Friday, Aug. 16, 2013. (AP Photo/Thomas Hartwell)

  • A poster left by supporters of ousted Egyptian President Mohammed Morsi remains outside Rabaah al-Adawiya mosque, in the center of the largest protest camp of Morsi supporters that was cleared by security forces, in the district of Nasr City, Cairo, Egypt, Friday, Aug. 16, 2013. (AP Photo/Hassan Ammar)

  • Egyptian government employees clean up outside the Rabaah al-Adawiya mosque in the center of the largest protest camp of supporters of ousted President Mohammed Morsi, that was cleared by security forces, in the Nasr City district of Cairo, Egypt, Friday, Aug. 16, 2013. (AP Photo/Hassan Ammar)

  • Egyptian government employees clean up as members of the Egyptians Army patrol among the smoldering remains of the largest protest camp of supporters of ousted President Mohammed Morsi, that was cleared by security forces, in the district of Nasr City, Cairo, Egypt, Friday, Aug. 16, 2013. (AP Photo/Hassan Ammar)

  • Egyptian army soldiers take their positions on top and next to their armored vehicles while guarding an entrance to Tahrir square, in Cairo, Egypt, Friday, Aug. 16, 2013. (AP Photo/Hassan Ammar)

  • Supporters of ousted Egyptian President Mohammed Morsi, cross the Nile as they march towards downtown Cairo from the Mohandeseen neighborhood of Cairo, Egypt, Friday, Aug. 16, 2013. (AP Photo/Thomas Hartwell)

  • Egyptian Army soldiers stand guard outside the Rabaah al-Adawiya mosque, background, in the center of the largest protest camp of supporters of ousted President Mohammed Morsi, that was cleared by security forces, in the district of Nasr City, Cairo, Egypt, Friday, Aug. 16, 2013. (AP Photo/Hassan Ammar)

  • A supporter of ousted Egyptian President Mohammed Morsi holding an ordinance, march towards downtown Cairo from the Mohandeseen district of Cairo, Egypt, Friday, Aug, 16, 2013. (AP Photo/Thomas Hartwell)

  • Supporters of ousted Egyptian President Mohammed Morsi march towards downtown Cairo from the Mohandeseen neighborhood of Cairo, Egypt, Friday, Aug, 16, 2013. (AP Photo/Thomas Hartwell)

  • Supporters of ousted Egyptian President Mohammed Morsi, one holding a picture of Morsi, cross the Nile as they march towards downtown Cairo from the Mohandeseen neighborhood of Cairo, Egypt, Friday, Aug. 16, 2013. (AP Photo/Thomas Hartwell)

  • Egyptian Army soldiers stand guard outside the Rabaah al-Adawiya mosque, in the center of the largest protest camp of supporters of ousted President Mohammed Morsi, that was cleared by security forces, in the district of Nasr City, Cairo, Egypt, Friday, Aug. 16, 2013. (AP Photo/Hassan Ammar)

  • Supporters of Egypt's ousted President Mohammed Morsi surround a coffin, covered with national flags, of their colleague who was killed during Wednesday' clashes in Amr Ibn Al-As mosque before a funeral prayers in Cairo, Egypt, Friday, Aug. 16, 2013. (AP Photo/Amr Nabil)

  • Supporters of Egypt's ousted President Mohammed Morsi throw stones at a gasoline station that belongs to the Egyptian Army service project, in Cairo, Egypt, Friday, Aug. 16, 2013. (AP Photo/Amr Nabil)

  • Supporters of ousted Egyptian President Mohammed Morsi run from Egyptian security forces firing towards them during clashes in Cairo's Nasr City district, Egypt, Wednesday, Aug. 14, 2013. (AP Photo/Manu Brabo)

  • Egyptian Muslim Brotherhood supporters run from police in a street leading to Rabaa al-Adawiya protest camp in Cairo on August 14, 2013.

  • Egyptian Muslim Brotherhood supporters run from police in a street leading to Rabaa al-Adawiya protest camp in Cairo on August 14, 2013.

  • Egyptian riot police are seen in a street leading to a camp of supporters of Egypt's ousted president in Cairo's Rabaa al-Adawiya as they try to disperse them on August 14, 2013.

  • Supporters of Egypt's ousted president Mohamed Morsi and members of the Muslim Brotherhood run from tear gas smoke shot by police to disperse a pro-Morsi camp, on August 14, 2013 in Cairo.

  • Supporters of Egypt's ousted president Mohamed Morsi and members of the Muslim Brotherhood run from tear gas smoke shot by police to disperse a pro-Morsi camp, on August 14, 2013 in Cairo.

  • Egyptian Muslim Brotherhood supporters run from tear gas fired by Egyptian police as they try to disperse supporters of Egypt's ousted president Mohamed Morsi in a street leading to the Rabaa al-Adawiya protest camp in Cairo on August 14, 2013.

  • Egyptians help a woman suffering from tear gas exposure after canisters were fired by Egyptian police as they try to disperse a pro-Morsi camp in a street leading to Rabaa al-Adawiya in Cairo on August 14, 2013.

  • A supporter of ousted Egyptian President Mohammed Morsi reacts during clashes with Egyptian security forces in Rabaah Al-Adawiya in Cairo's Nasr City district, Egypt, Wednesday, Aug. 14, 2013. (AP Photo/Manu Brabo)

  • An Egyptian security force checks his weapon as they clear a sit-in camp set up by supporters of ousted Islamist President Mohammed Morsi near Cairo University in Cairo's Giza district, Egypt, Wednesday, Aug. 14, 2013. (AP Photo/Hussein Tallal)

  • Egyptian security forces takes a break as they clear a sit-in camp set up by supporters of ousted Islamist President Mohammed Morsi near Cairo University in Cairo's Giza district, Egypt, Wednesday, Aug. 14, 2013. (AP Photo/Hussein Tallal)

  • Supporters of ousted Islamist President Mohammed Morsi walk through their sit-in camp as Egyptian security forces clear the sit-in camp set up near Cairo University in Cairo's Giza district, Egypt, Wednesday, Aug. 14, 2013. (AP Photo/Hussein Tallal)

  • Supporters of ousted Egyptian President Mohammed Morsi take cover from Egyptian security forces fire during clashes in Rabaah Al-Adawiya in Cairo's Nasr City district, Egypt, Wednesday, Aug. 14, 2013. (AP Photo/Manu Brabo)

  • Egyptian security forces detain supporters of ousted Islamist President Mohammed Morsi as they clear a sit-in camp set up near Cairo University in Cairo's Giza district, Egypt, Wednesday, Aug. 14, 2013. (AP Photo/Hussein Tallal)

  • Supporters of ousted Islamist President Mohammed Morsi come out of their makeshift hut at their sit-in camp as Egyptian security forces clear the camp set up near Cairo University in Cairo's Giza district, Egypt, Wednesday, Aug. 14, 2013. (AP Photo/Hussein Tallal)

  • A supporter of ousted Islamist President Mohammed Morsi runs to avoid smoke and tear gas as Egyptian security forces clear a sit-in camp set up near Cairo University in Cairo's Giza district, Egypt, Wednesday, Aug. 14, 2013. (AP Photo/Hussein Tallal)

  • A man tends a supporter of ousted Islamist President Mohammed Morsi as Egyptian security forces clear a sit-in camp set up near Cairo University in Cairo's Giza district, Egypt, Wednesday, Aug. 14, 2013. (AP Photo/Hussein Tallal)

  • Egyptian security forces and a man carry a man as security forces clear a sit-in camp set up by supporters of ousted Islamist President Mohammed Morsi near Cairo University in Cairo's Giza district, Egypt, Wednesday, Aug. 14, 2013. (AP Photo/Hussein Tallal)

  • An Egyptian security force escorts a supporter of ousted Islamist President Mohammed Morsi as security forces clear a sit-in camp set up near Cairo University in Cairo's Giza district, Egypt, Wednesday, Aug. 14, 2013. (AP Photo/Hussein Tallal)

  • A supporter of ousted Islamist President Mohammed Morsi raises his arm as Egyptian security forces detain him at a sit-in camp set up near Cairo University in Cairo's Giza district, Egypt, Wednesday, Aug. 14, 2013. (AP Photo/Hussein Tallal)