Hosni Mubarak was supposed to announce his resignation on Thursday. The Egyptian military expected it. The new head of his ruling party pleaded to him face-to-face to do it. But despite more than two weeks of massive demonstrations by protesters unmoved by lesser concessions, the president still didn’t get it.

Mubarak’s top aides and family — including his son Gamal, widely viewed as his intended successor — told him he could still ride out the turmoil. So the televised resignation speech the rest of Egypt had expected became a stubborn — and ultimately humiliating — effort to cling to power. It only enraged protesters. On Friday, the military moved decisively.

On Saturday, insiders in Egypt gave The Associated Press an initial picture of what happened in the hours before Egypt’s “unoustable” leader of nearly 30 years fell. Some of them spoke on condition of anonymity because of the sensitivity of the information.

Their account portrayed Mubarak as unable, or unwilling, to grasp that nothing less than his immediate departure would save the country from the chaos generated by the protests that began Jan. 25. A senior government official said Mubarak lacked the political machinery that could give him sound advice about what was happening in the country.

“He did not look beyond what Gamal was telling him, so he was isolated politically,” said the official. “Every incremental move (by Mubarak) was too little too late.”

The military, meanwhile, was becoming increasingly impatient with the failure of Mubarak and Omar Suleiman, his newly appointed vice president, to end the protests. The unrest spiraled out of control Thursday and Friday, with demonstrations, strikes, sit-ins and even gunbattles engulfing almost the entire nation.

Insiders spoke of fighting among Cabinet ministers over how great a threat the demonstrators posed, and of deliberate attempts by close aides, including Gamal Mubarak, to conceal from the president the full extent of what was happening on the streets.

The insiders who spoke to the AP include a senior Egyptian official, editors and journalists from state newspapers close to the regime who have spent years covering Mubarak’s presidency, retired army generals in contact with top active duty officers, senior members of Mubarak’s National Democratic Party and analysts familiar with the machinations of Mubarak’s inner circle.

Their account of the events of the past three weeks shows that the military became concerned soon after the protests began. They said it was the military that persuaded Mubarak to appoint Suleiman as vice president — the first since Mubarak took office in 1981 — and place him in charge of negotiations with opposition groups on a way out of the standoff.

Suleiman failed on that score — on Tuesday he was reduced to threatening that a coup would replace the negotiations if no progress was made. Leaders of the protests vowed not to negotiate until Mubarak was gone, even after he said he would not seek another term in September and promised reforms to reduce poverty, end repressive emergency laws and make Egypt more democratic.

By Thursday, nearly everyone had expected Mubarak to resign, including the military.

Hossam Badrawi, a stalwart of Mubarak’s National Democratic Party, met with Mubarak on Thursday and later told reporters that he expected the Egyptian leader to “meet people’s demands” — read that stepping down — later the same day. After Mubarak did not, Badrawi, who had been named the party’s secretary general a few days earlier, resigned in protest, according to two party insiders.

Meanwhile, the military’s highest executive body — The Supreme Council of the Armed Forces — met without its chairman, commander-in-chief Mubarak, and issued a statement recognizing the “legitimate” rights of the protesters. They called the statement “Communique No. 1,” language that in the Arab world suggests a a coup was taking place.

Insiders said Mubarak’s address Thursday night was meant to be his resignation announcement. Instead, he made one last desperate attempt to stay in office after being encouraged to do so by close aides and especially by his family, long the subject of rumors of corruption, abuse of power and extensive wealth.

One insider said Gamal, his banker-turned-politician son, rewrote the speech several times before the recording. It was aired at 11 p.m., several hours after state TV said Mubarak was about to address the nation. It showed brief footage of him meeting with Suleiman and his Prime Minister Ahmed Shafiq.

The address was clearly prepared in a rush. It had rough cuts, and Mubarak was caught at least once acting like he was between takes, fixing his tie and looking away from the camera.

Information Minister Anas al-Fiqqi was there at the studio alongside Gamal Mubarak, according to two of the insiders. State TV quoted him in the hours before the broadcast saying that Mubarak would not resign. On Saturday, al-Fiqqi announced his own resignation.

Mubarak said in the address that he was handing over most of his powers to Suleiman but again rejected calls for his resignation. He vowed to introduce genuine reforms, prosecute those behind the violence that left scores of protesters dead and offered his condolences to the victims’ families. He said he was hurting over calls for his removal and, in his defense, recounted his record in public service. He was not going anywhere until his term ended in September, he said.

He had hoped that putting Suleiman in charge would end the protests and allow him to remain in office as a symbolic figure, a scenario that would have seen him make a dignified exit.

The address betrayed what many Egyptians suspected for years — Mubarak was out of touch with the people.

Mubarak, said a senior Egyptian official, “tried to manage the crisis within the existing structures and norms. That was clearly too late. The incremental offers of reform also were clearly insufficient.”

The insiders differ on whether Mubarak’s address that night was made with the consent of the military, whether it represented his last chance to take back control of the streets. Even if the military’s patience wasn’t exhausted by the speech, it ran out as the protests grew more intense.

On Friday, the military allowed protesters to gather outside Mubarak’s presidential palace in a Cairo suburb — but by that time Mubarak and his immediate family had already flown to another palace in the Red Sea resort of Sharm el-Sheikh, 250 miles away. The soldiers also allowed protesters to besiege the TV and radio building in downtown Cairo. Two days earlier, the military stood by and watched as protesters laid siege to the prime minister’s office and parliament. Shafiq, the prime minister, could not work in his office and had to work out of the Civil Aviation Ministry close to Cairo’s airport.

By early afternoon, millions were out on the streets in Cairo, the Mediterranean port city of Alexandria and a string of other major cities. The crowd outside his palace was rapidly growing. Only a few meters and four army tanks separated the protesters from the gate.

Suleiman, Mubarak’s longtime confidant and a former intelligence chief, announced that Mubarak was stepping down. In a two-sentence statement to state television that took 49 seconds, Egypt’s history changed forever.