Into the Hands of the Soldiers: Freedom and Chaos in Egypt and the Middle East. By David Kirkpatrick. Viking; 384 pages; $28. Bloomsbury Publishing; £21.

IN 2005 a middle-aged Egyptian army officer arrived in Carlisle, Pennsylvania. While taking classes at the US Army War College, the officer, a devout Muslim, sometimes led Friday prayers at the local mosque. During campus debates he took exception to those who claimed that political Islam was incompatible with democracy. In his final paper he argued that Arab democracies must include Islamists, even “radical ones”.

So when the Muslim Brotherhood, Egypt’s main Islamist movement, won the country’s first free and fair elections in 2011-12, the officer, Abdel-Fattah al-Sisi, seemed keen to work with the group. He was appointed defence minister and quickly gained the trust of the new president, Muhammad Morsi, a Brotherhood leader. Mr Sisi would show up at meetings with his sleeves rolled up and hands wet, as though he had been washing himself for prayer. Yet, less than two years later, he ousted Mr Morsi, slaughtered hundreds of his followers and imprisoned what was left of the Brotherhood’s leadership.

Egypt, where a quarter of Arabs live, has always been something of an enigma. Despite the public’s disenchantment with Hosni Mubarak, the long-term dictator, few predicted the revolution of 2011 that laid the groundwork for Mr Morsi’s election and Mr Sisi’s subsequent coup. “Nothing is going to happen in Egypt,” editors at the New York Times told David Kirkpatrick when he took over the paper’s Cairo bureau at the start of 2011. Weeks later Mr Mubarak was toppled and the political order was thrown into disarray. In the years that followed, soldiers, Islamists, liberals and the old elite jostled for power. None could be trusted.

In his new book, “Into the Hands of the Soldiers”, Mr Kirkpatrick describes these tumultuous times in compelling detail. The author is honest about how hard it was to interpret events, grasp the motives of people such as Mr Sisi and Mr Morsi and predict the direction in which Egypt was heading. “I brought with me the standard Western assumptions,” he admits. “Almost all of it was wrong.” But Mr Kirkpatrick, who dodged bullets and official harassment, deciphered the mystery. The same cannot be said of the foreign powers, especially America, that watched as Egypt’s democracy crumbled.

The Islamist riddle

The Brotherhood was Egypt’s biggest puzzle. “For a supposedly secret society, they were easy to spot,” writes Mr Kirkpatrick. Often middle-aged and middle-class, they kept their beards trimmed and wore chinos and button-down shirts. But, before the revolution, their intentions were difficult to discern. When Hassan al-Banna founded the group in 1928 he was fuzzy on whether it should be militant or peaceful, political or spiritual, democratic or authoritarian. Egypt’s dictators by turns persecuted, embraced and tolerated the Brotherhood. America, which lavishes military aid on Egypt, followed their lead.

Opponents of the Brotherhood warned foreign journalists that the group wanted to “Islamise” Egypt. But to Mr Kirkpatrick—and your reviewer, a former Cairo correspondent—the Brothers said all the right things. They advocated the separation of mosque and state, free expression and equality for women and non-Muslims. These views were more liberal than those of mainstream Egyptians. Moreover, to avoid a backlash, the group said during the uprising that it would not seek more than a third of parliamentary seats; later it said it would not field a presidential candidate in the polls following the revolution.

But when those elections came around, the Brotherhood contested most of the seats, winning nearly half and also the presidency. After his victory, Mr Morsi installed Brothers in powerful positions. Months later he issued a decree holding himself above judicial review and pushed through a constitution opposed by liberals. “We thought we were losing our country,” one young Egyptian told The Economist. Millions took to the streets in 2013 calling for Mr Morsi to go. Egypt’s so-called liberals saw those protests as a rerun of the 2011 revolution—another organic uprising; another chance for democracy, as they defined it.

They were nothing of the sort. Egypt’s liberals were not taking back the country—the army was. A slow-motion coup had been in the works since Mr Morsi was elected. Egypt’s generals did not even want to recognise his victory. Mubarak-era judges duly dissolved the parliament. The president’s own foreign minister, a non-Islamist, admitted to poisoning other governments against him, while the intelligence services worked covertly to bring the Brotherhood down. The United Arab Emirates, whose authoritarian rulers fear democracy, especially if it has an Islamic tint, funnelled millions of dollars to the supposedly grassroots opposition to Mr Morsi. Much of it went through Mr Sisi’s defence ministry.

The coup befuddled America. As Mr Morsi teetered, “Washington did not speak with a single, credible voice,” writes Mr Kirkpatrick. Barack Obama, then America’s president, opposed the takeover and leant on Mr Morsi to make concessions to save his skin. (Mr Morsi did invite the opposition for talks—they declined.) But many American officials seemed resigned to, or even encouraged, a military power-grab. Chuck Hagel, then secretary of defence, told Mr Sisi: “I don’t live in Cairo, you do. You do have to protect your security, protect your country.” John Kerry, then secretary of state, said later that the generals “were restoring democracy”.

American officials couldn’t get their facts right. James Mattis, then the commander of American forces in the region, blamed the Brotherhood alone for Egypt’s troubles. He later claimed that the constitution backed by Mr Morsi had been “rejected immediately by over 60% of the people”. In fact, about two-thirds of voters approved the charter, which is similar to the one Egypt has now. Mr Mattis and Michael Flynn, then head of the Defence Intelligence Agency, lumped the Brotherhood in with the jihadists of al-Qaeda and Islamic State, even though the Brothers repeatedly condemned those groups and opposed violence. Both men were given top jobs by Donald Trump.

It is true that the roots of al-Qaeda and other jihadist groups can be traced back to Egyptian jails, which began filling with resentful Islamists in the 1960s. Now the jails are bursting again, so much so that new ones have had to be built. The Islamists have been joined by liberals, who quickly soured on Mr Sisi’s inept and draconian rule. Egypt now holds about 30,000 political prisoners, including many journalists. Your reviewer was berated by the foreign ministry for, among other things, referring to Mr Sisi’s takeover as a coup (a label America refused to apply). Mr Kirkpatrick had it worse. Talk-show hosts denounced him on air as an enemy of the state.

The coup also fuelled a jihadist insurgency in Sinai that continues to torment Egypt. Yet American officials, citing renewed “stability”, argued that the Brotherhood’s overthrow was the least bad option. The alternative “wasn’t Jeffersonian democracy”, Mr Kerry tells the author. “Over whatever number of years we have put about $80bn into Egypt. Most of the time, this is the kind of government they had—almost all of the time. And the reality is, no matter how much I wish it was different, it ain’t going to be different tomorrow.”

Today’s American administration does not even wish it were different. To them, Mr Sisi has said all the right things. He wants to moderate Islam and reform the economy. He calls Mr Trump “a unique personality that is capable of doing the impossible”. Mr Trump, in turn, celebrates Mr Sisi’s tough leadership and calls him “a fantastic guy”. Like so many others, the American president seems unconcerned that autocracy is again breeding misery and extremism in Egypt.