CAIRO -- For a moment, at least, American and European diplomats trying to defuse the volatile standoff in Egypt thought they had a breakthrough.
As thousands of Islamist supporters of the ousted president, Mohamed Morsi, braced for a crackdown by the military-imposed government, a senior European diplomat, Bernardino León, told the Islamists of "indications" from the leadership that within hours they would free two imprisoned opposition leaders. In turn, the Islamists had agreed to reduce the size of two protest camps by about half.
An hour passed and nothing happened. Another hour passed, and still no one had been released.
The Americans heightened the pressure. Two senators visiting Cairo, John McCain of Arizona and Lindsey Graham of South Carolina, met with Gen. Abdul-Fattah el-Sisi, the officer who ousted Mr. Morsi and appointed the new government, and the interim prime minister, Hazem el-Beblawi, and pushed for the release of the two prisoners. But the Egyptians brushed them off.
"You could tell people were itching for a fight," Mr. Graham recalled in an interview. "The prime minister was a disaster. He kept preaching to me, 'You can't negotiate with these people, they've got to get out of the streets and respect the rule of law.' I said: 'Mr. Prime Minister, it's pretty hard for you to lecture anyone on the rule of law. How many votes did you get? Oh yeah, you didn't have an election.' "
General Sisi, Mr. Graham said, seemed "a little bit intoxicated by power."
The senators walked out that day, Aug. 6, gloomy and convinced that a violent showdown was looming. But the diplomats still held out hope, believing they had persuaded Egypt's government at least not to declare the talks a failure.
The next morning, the government issued a statement declaring that diplomatic efforts had been exhausted and blaming the Islamists for any casualties from the coming crackdown. A week later, Egyptian forces opened a ferocious assault that so far has killed more than 900 protesters.
All of the efforts of the United States government, all the cajoling, the veiled threats, the high-level envoys from Washington and the 17 personal phone calls by Defense Secretary Chuck Hagel, all failed to forestall the worst political bloodletting in modern Egyptian history. The generals in Cairo felt free to ignore the Americans first on the prisoner release and then on the statement, in a cold-eyed calculation that they would not pay a significant cost -- a conclusion bolstered when President Obama responded by canceling a joint military exercise but not $1.5 billion in annual aid.
For Mr. Obama, the violent crackdown has left him in a no-win position: risk a partnership that has been the bedrock of Middle East peace for 35 years, or stand by while longtime allies try to hold on to power by mowing down opponents. From one side, he has been lobbied by the Israelis, Saudis and other Arab allies to go easy on the generals in the interest of thwarting what they see as the larger and more insidious Islamist threat. From the other, he has been urged by an unusual mix of conservatives and liberals to stand more forcefully against the sort of autocracy that has been a staple of Egyptian life for decades.
For now the administration has decided to keep the close relationship with the Egyptian military fundamentally unchanged. But the death toll is climbing, the streets are descending into chaos and the government and the Islamists are vowing to escalate. It is unclear if the military's new government can reimpose a version of the old order now that the public believes street protests have toppled two leaders in less than three years, or if, after winning democratic elections, the Islamists will ever again compliantly retreat.
As Mr. Obama acknowledged in a statement on Thursday, the American response turns not only on humanitarian values but also on national interests. A country consumed by civil strife may no longer function as a stabilizing ally in a volatile region.
An Enduring Headache
Mr. Obama has found Egypt's tumultuous political transition a headache for more than two years. Accused of sticking for too long by President Hosni Mubarak, the longtime ruler in Egypt who was ousted by a popular uprising in 2011, and then criticized when he later abandoned him, Mr. Obama gambled on Mr. Morsi, the Muslim Brotherhood leader elected a year ago. He found Mr. Morsi a useful and pragmatic partner in handling issues like a violent flare-up in Gaza. But Mr. Obama became convinced that the Egyptian was not being inclusive enough at home to stabilize his own country.
When Secretary of State John Kerry visited Cairo last spring, he urged Mr. Morsi to reach out to his opposition. If not, Mr. Kerry warned, Mr. Morsi would set the stage for another uprising, this time against himself. But the implied threat only hardened Mr. Morsi's resolve not to bend, his aides said.
Mr. Morsi's failure to incorporate other factions, his habit of demonizing his critics as part of a treasonous conspiracy and a near-calamitous economic crisis combined to fire up opposition to the Islamists, which spilled out in street protests. Hard-liners with the military and intelligence services who always despised the Muslim Brotherhood saw that the group's experiment in power might have left it more vulnerable than at any time in its eight decades underground.
The Obama administration warned the military against stepping in, noting that a coup would require an aid cutoff under American law. But on July 3 the military moved in, detaining Mr. Morsi at an undisclosed location and rounding up scores of his allies.
Mr. Obama made no public comments, opting instead for tempered written statements. He skirted the aid law by refusing to determine whether Mr. Morsi's ouster constituted a coup, while Mr. Kerry and Mr. Hagel pressed the military to restore civilian governance as soon as possible.
Western governments took a wait-and-see approach even after the military committed its first mass killing, shooting more than 60 supporters of Mr. Morsi at a sit-in on July 8. Western diplomats did not engage in earnest until July 24, when General Sisi, in dark sunglasses and military regalia, delivered a fiery speech asking the public to turn out for demonstrations giving him a "mandate" to take on the Islamists. Security forces killed 80 more Morsi supporters in their second mass shooting on the day of the demonstration.
The next morning, Morsi aides and Brotherhood leaders say, their phones began ringing with American and European diplomats fearing an imminent blood bath.
The administration enlisted players on opposite sides of the contest playing out in Egypt. Diplomats from Qatar, a regional patron of the Muslim Brotherhood, agreed to influence the Islamists. The United Arab Emirates, determined opponents of the Islamists, were brought in to help reach out to the new authorities.
But while the Qataris and Emiratis talked about "reconciliation" in front of the Americans, Western diplomats here said they believed the Emiratis were privately urging the Egyptian security forces to crack down.
Abdullah bin Zayed al-Nahyan, the Emirati foreign minister, came to Washington last month and urged the Americans not to cut off aid. The emirates, along with Saudi Arabia, had swiftly supported the military takeover with a pledge of billions of dollars, undermining Western threats to cut off critical loans or aid.
The Israelis, whose military had close ties to General Sisi from his former post as head of military intelligence, were supporting the takeover as well. Western diplomats say that General Sisi and his circle appeared to be in heavy communication with Israeli colleagues, and the diplomats believed the Israelis were also undercutting the Western message by reassuring the Egyptians not to worry about American threats to cut off aid.
The Israeli government issued a statement late Saturday denying that claim as "baseless and without foundation."
When Senator Rand Paul, Republican of Kentucky, proposed an amendment halting military aid to Egypt, the influential American Israel Public Affairs Committee sent a letter to senators on July 31 opposing it, saying it "could increase instability in Egypt and undermine important U.S. interests and negatively impact our Israeli ally." Statements from influential lawmakers echoed the letter, and the Senate defeated the measure, 86 to 13, later that day.
Mr. Obama agreed not to restrict the aid, but did postpone the delivery of four F-16 fighter jets. At the time, officials also discussed pulling out of joint military exercises called Bright Star scheduled for September, but the White House opted to wait to see if the generals would follow through on their threat to clear out pro-Morsi protesters.
Mr. Hagel tried to forge a connection with General Sisi, the defense minister who has become the country's de facto leader. Mr. Hagel, a 66-year-old decorated Vietnam veteran, felt he and General Sisi, a 58-year-old graduate of the United States Army War College in Pennsylvania, "clicked right away" when they met in April, an American official said.
In a series of phone calls, Mr. Hagel pressed General Sisi for a transition back to civilian rule. They talked nearly every other day, usually for an hour or an hour and a half, lengthened by the use of interpreters. But General Sisi complained that the Obama administration did not fully appreciate that the Islamists posed an existential threat to Egypt and its army. The general asked Mr. Hagel to convey the danger to Mr. Obama, American officials said.
"Their whole sales pitch to us is that the Muslim Brotherhood is a group of terrorists," said one American officer, who was not authorized to speak publicly about the dialogue.
American and European diplomats hoped to reinforce the very few officials in Egypt's interim cabinet who favored an inclusive approach, led by Mohamed ElBaradei, the vice president and Nobel Peace Prize-winning former diplomat. After the second massacre, on July 26, Mr. ElBaradei wanted to resign, but Mr. Kerry talked him out of it, arguing that he was the most potent voice for restraint, if not the only one, inside the government.
But General Sisi never trusted Mr. ElBaradei, and on the other side was a small core of military officers close to the general who saw a chance to finally rid Egypt of the Muslim Brotherhood. Among them were Gen. Mohammed al-Tohami, a mentor and father figure to General Sisi and now head of the intelligence service, and Gen. Mahmoud Hegazy, the general's protégé and chosen successor as head of military intelligence. And with no serious reprisals against Egypt after two mass killings, many analysts here argue that the hard-liners could only feel emboldened.
Mr. Kerry sent his deputy, William J. Burns, to Cairo, who with a European Union counterpart scrambled to de-escalate the crisis.
Under a plan they worked out, the Muslim Brotherhood would limit demonstrations to two squares, thin out crowds and publicly condemn violence. The government would issue a similar statement, commit to an inclusive political process allowing any party to compete in elections and, as a sign of good faith, release Saad al-Katatni, the Muslim Brotherhood speaker of the dissolved Parliament, and Aboul-Ela Maadi, founder of a more moderate Islamist party. Both faced implausible charges of instigating violence, and Western diplomats felt that in the prelude to the takeover, Mr. Katatni in particular had proven himself a pragmatic voice for compromise.
But on Aug. 4, the interim government surprised the diplomats by bringing charges for incitement to murder against the Brotherhood's supreme guide, Mohamed Badie, who was in hiding, and Khairat el-Shater, its most influential leader, who had been detained.
Adding to the shock of the new charges, they came just hours before Mr. Burns and his European partner, Mr. León, were allowed to see Mr. Shater. Mr. Shater embraced the need for dialogue but did not endorse the proposals.
Still, the diplomats grew hopeful they had gotten through to the government. On the morning of Aug. 6, Brotherhood leaders and diplomats said, Mr. León called Amr Darrag, an adviser to Mr. Morsi and top negotiator for the Islamist coalition, and told him to expect Mr. Katatni and Mr. Maadi to be released within hours. When nothing happened, Mr. Darrag called Mr. León back, the Brotherhood officials said. Do not worry, Mr. León said, arguing that the new government must have put the release off by a day to avoid the appearance of bowing to American pressure.
Mr. McCain and Mr. Graham arrived in Cairo amid increasing tensions. They went first to see Ambassador Anne W. Patterson. "You could see it on her face, that nobody's listening," Mr. Graham said. He said administration officials asked them to press for the release of the two Islamists and to push the Brotherhood to pull people off the street.
When the senators asked government officials to release the Islamist leaders, one woman on the Egyptian side stormed out. The senators warned that the United States would ultimately cut off aid if the military did not set elections and amend the Constitution.
Mr. Graham recalled arguing with General Sisi. "If Morsi had to stand for re-election anytime soon, he'd lose badly," the senator remembered saying. "Do you agree?"
"Oh, absolutely," the general answered.
"Then what you're doing now is making him a martyr," Mr. Graham said. "It's no longer about how badly they ruled the country and how they marginalized the democratic institutions. It's now about you."
The meeting with the prime minister was even tenser. As they walked out, Mr. Graham said he told Mr. McCain, "If this guy's voice is indicative of the attitude, there's no pulling out of this thing."
When Egyptian state news media leaked reports of an imminent government statement that diplomacy had failed, the diplomats were stunned, and scrambled to hold it off.
The next day, Mr. León, the European envoy, assured the Islamists that although the prisoner release had fallen through, at least the Egyptians had agreed to pull back the statement, Brotherhood leaders said.
A half-hour later, it was issued nonetheless. "The phase of diplomatic efforts has ended," it declared, calling the sit-ins "nonpeaceful" and obliquely blaming the Muslim Brotherhood for any coming violence.
The Americans and Europeans were furious, feeling deceived and manipulated. "They were used to justify the violence," Mr. Darrag said in an interview. "They were just brought in so that the coup government could claim that the negotiations failed, and in fact, there were no negotiations."
Mr. Burns left Cairo with a sense of foreboding. Western diplomats in Cairo said that, despite their public statements at the time to the contrary, it was then that they, too, gave up hope.
Mr. Hagel made a last stab at holding off violence. He called General Sisi late on the afternoon of Friday, Aug. 9, and they talked for 90 minutes. "Secretary Hagel was strongly urging restraint," said an American official briefed on the conversation. The secretary recited the same talking points he had been delivering for weeks: avoid violence, respect freedom of assembly and move toward an inclusive political transition.
But within the Egyptian government, the only real debate was about tactics and blame. Mohamed Ibrahim, the interior minister under Mr. Morsi who had kept his job by refusing to protect the Islamists, was convinced that brute force was the only way to break up sit-ins by tens of thousands of Morsi supporters. But diplomats and Egyptian officials familiar with the debate said Mr. Ibrahim was worried that if the assaults went badly he might be held up as a scapegoat.
Last Sunday, Interior Ministry officials told journalists that the police would move in at dawn to choke off the sit-ins, cutting off food and water and gradually escalating nonlethal force. But overnight, diplomats said, Mr. Ibrahim reconsidered, worried that a gradual approach would expose the police to Brotherhood retaliation, for which he could be blamed.
Two days later, Mr. Ibrahim and the government told Mr. ElBaradei they had a new plan to minimize casualties: maximum force to get it over with quickly, the Western diplomats said. And the military had agreed to support the police. But the attack the next morning left more than 600 dead, according to official figures that soon grew. By midday, Mr. ElBaradei resigned.
As images of Egyptian security forces opening fire flickered across television screens in Washington, Mr. Hagel called General Sisi again and warned him that the violence had put "important elements of our longstanding defense cooperation at risk," as he put it in a statement afterward. Mr. Kerry made the same points in tandem to the interim foreign minister, Nabil Fahmy.
Mr. Obama announced the cancellation of Bright Star exercises without saying anything about the aid. As of Friday, American officials were still working phone lines to Cairo. Mr. Kerry talked with his Egyptian counterpart, urging the government to appoint an envoy to negotiate directly with the Islamists, United States officials said. But the diplomats and military officers in the two countries seemed to be talking past each other.
"The million-dollar question now," said one American military officer, "is where is the threshold of violence for cutting ties?"
David D. Kirkpatrick reported from Cairo, and Peter Baker and Michael R. Gordon from Washington. Reporting was contributed by Eric Schmitt, Mark Mazzetti and Thom Shanker from Washington, Mark Landler from Chilmark, Mass., and Steven Erlanger from London.
This article originally appeared in The New York Times.