Updated

It was one of the most perplexing events of Egypt's revolution: orchestrated attacks on prisons around the country that broke out more than 20,000 inmates while police were tied down with the massive popular protests that swept autocrat Hosni Mubarak from power.

The prison breaks added to the chaos during the 18-day uprising in 2011, and the flood of criminals onto the streets fueled a crime wave that continues to this day. Also among those who escaped were around 40 members of the Palestinian militant group Hamas and Lebanon's Hezbollah, as well as more than 30 leaders of Egypt's Muslim Brotherhood — including the man who is now president, Mohammed Morsi.

There has never been a definitive accounting of who was behind the prison attacks.

But now the question has become a political headache for Morsi. A judge — from a judiciary branch where opposition to the Islamist president is strong — has turned an ongoing court case into the first public investigation of the jail breaks, calling in prison officials to testify on what happened.

A string of top police, prison and intelligence officials have put the blame on Hamas, a close ally of Morsi's Muslim Brotherhood, saying the militant group sent fighters from Gaza to join with Bedouin from Sinai to storm prisons and break free the jailed Hamas members.

In Egypt's polarized political climate, Morsi's opponents are using the issue against him, saying friends of the Brotherhood violated the country's security and fed its instability. The eagerness of some in the intelligence and security agencies to blame Hamas could in part reflect resentment of the Brotherhood's ties with the militant group, which they have long seen as a threat.

Hamas vehemently denies any role in the attacks — and so far, the court case, currently being heard in the Suez Canal city of Ismailia, has produced no proof of its involvement.

Saad el-Husseini, who was among the Brotherhood leaders freed in the break and who is now a provincial governor, said the accusations against Hamas were "an attempt to slander" Morsi. He denied there were attacks on the prisons, telling reporters this month it was the police who opened the jails amid the confusion of the uprising.

Morsi and the other Brotherhood figures were detained in a sweep against the group just after the wave of protests against Mubarak began on Jan. 25, 2011. They were held in the Wadi el-Natroun prison complex north of Cairo without charge under emergency laws and escaped about two days after their detention.

Some critics argue that Morsi is a fugitive in the eyes of the law since he did not turn himself in after his escape, a crime punishable by up to two years in prison.

With the Ismailia trial now making front-page headlines in Egypt's newspapers, the interior minister, who is in charge of prisons and police, sought to deflect charges that Morsi broke the law by escaping. Mohammed Ibrahim, who was appointed by Morsi, told a May 11 news conference that Morsi's name was never officially entered as a detainee, suggesting he therefore could not be considered a fugitive.

The Associated Press asked Morsi's office for comment in repeated e-mails. In a response last week, the presidency pointed to Ibrahim's comments and did not reply to requests for further elaboration.

The Ismailia case started about six months ago as a trial for an inmate who allegedly escaped from Wadi el-Natroun in the same prison break but was later caught by police and faced charges of failing to turn himself in.

Since then, the judge, Khaled Mahgoub, and defense lawyers have dramatically expanded the case to investigate the prison attacks themselves, calling a series of officials from the stormed prisons. The lawyers have requested Morsi and intelligence officials also testify, saying they want to determine whether the Brotherhood invited Hamas to carry out the prison breaks. Mahgoub has yet to rule on these requests.

Prosecutors have called on Mahgoub to stop the testimonies and acquit the defendant. Mahgoub has also received a written death threat, prompting police to assign two guards to his home.

So far, the prison officials have testified that their facilities came under highly organized attacks by heavily armed gunmen from Gaza and Sinai starting on Jan. 28, 2011. In all, 11 of Egypt's more than 40 prisons saw jail breaks.

The officials said gunmen in pickup trucks and SUVs with machine guns and earthmoving equipment to break down walls overwhelmed guards, while prisoners inside rioted.

"They came in so many cars I could not count them," a prison official from Wadi el-Natroun, police Gen. Essam el-Qoussi, told AP. He said they wore Bedouin-style robes or military-style outfits and spoke Arabic in the accents of Sinai and Gaza.

"It was like doomsday for us," he said. The attackers "fought with our guards for about 90 minutes." A total of 14 inmates were killed when the prison was forced open.

A number of senior security officials have publicly accused Hamas.

"Definitely, Hamas played a big part in storming the prisons and all intelligence points to that," Mansour el-Issawi, who served as the first post-Mubarak interior minister, told the independent Al-Masry Al-Youm newspaper in April.

A Military Intelligence official told AP that beginning on Jan. 27, 2011, bands of fighters from Gaza began entering Sinai through cross-border tunnels, bringing ammunition, machineguns and mines. They were met by Sinai Bedouin in SUVs, he said.

At the same time, Bedouin attacked police positions near the border as a diversion, he said, speaking on condition of anonymity because he was not authorized to talk to the press.

The Hamas and Hezbollah prisoners were freed in attacks on two other prisons, el-Marg and Abu Zaabal.

Jan. 28 was a tumultuous day in the 2011 uprising. In Cairo and other cities, protesters demanding Mubarak's ouster fought street battles with security forces. The police were so shattered they withdrew from the streets around the country for the rest of the revolution — and in fact, they have never fully returned to duty.

Amid the confusion, little was clear about the prison breaks. Many believed that police, furious over the uprising, freed prisoners to create pandemonium. But witnesses at the time reported that Bedouin stormed the prisons to free family members.

The Brotherhood figures who escaped have said they had no idea what was going on.

Several have said they were locked in a separate cell block at Wadi el-Natroun while, during the night, other prisoners staged a break and police fled. Most prisoners escaped, but the Brotherhood members were trapped in their block until hours later when a few prisoners who were still there and their families broke open the door for them.

Morsi's only account came in a frantic phone call he made to Al-Jazeera Mubasher TV moments after being freed.

"From the noises we heard ... It seemed to us there were (prisoners) attempting to get out of their cells and break out into the prison yard and the prison authorities were trying to regain control and fired tear gas," Morsi said in the call.

By the time they got out, the prison was empty, and there was no sign of a major battle, he said.

Ali Ezz, a senior Brotherhood figure who escaped with Morsi, also told AP that they had been trapped in the block while most others fled. "We could have been left to die in that prison," he said.

He said testimonies about a force of Bedouin and Gazan fighters were "baseless."

A senior commander of Hamas' military wing told the AP in Gaza that allegations of the group's involvement aim to undermine Morsi and whip up anti-Hamas sentiment among Egyptians.

"The story about armed cars and SUVs with machine guns driving 700 kilometers from Gaza to Egypt and then back is silly," he said, speaking on condition of anonymity because he was not authorized to talk about the case.

"We didn't go in to free the prisoners simply because we were not aware of what exactly was going on. Why take the risk and send people in and who will protect them?"