During his 2016 campaign, Donald Trump suggested Islam might be inherently violent, claimed that Muslims in Jersey City had cheered on 9/11, and promised to ban all Muslims from entering the US.

It came as a surprise then that Trump was greeted by Egyptian president Abdel Fattah el-Sisi and Prince Mohammed bin Salman of Saudi Arabia with deep admiration and labeled a "friend of all Muslims."

As an international correspondent for the New York Times in Egypt, I watched Trump enter Middle Eastern politics amidst one of Egypt's most difficult periods in recent history.

The following is an excerpt from "Into the Hands of the Soldiers: Freedom and Chaos in Egypt and the Middle East" by David D. Kirkpatrick:

I watched much of the 2016 presidential race from Cairo, and that vantage point made the discussion of the Middle East especially bracing.

Candidate Donald J. Trump's hostility to Islam was blunt and unmistakable. He made a point of saying "radical Islam" instead of "Islamic radicalism" to underscore that the creed itself was the problem. He promised to bar all Muslims from entering the United States. He claimed Muslims in Jersey City had cheered for the destruction of the World Trade Center on 9/ 11. He told apocryphal stories glorifying the killing of Muslim fighters with bullets soaked in pig fat. He even insinuated that Obama himself was a crypto-Muslim. So how would Trump get along with Sisi, who had pledged as president of Egypt to teach and defend Islam?

Viking They adored each other. Sisi leaped to excuse the candidate's promise to ban Muslims. It was just campaign talk, Sisi told CNN. He was the first foreign leader to congratulate Trump on election night, and when they met at the White House, Sisi seized the new president's outstretched hand with the awkward eagerness of a teenager meeting his idol. "I have had a deep appreciation and admiration of your unique personality," Sisi told Trump.

"A fantastic guy," Trump called Sisi when they first met, in September 2016, and again during Sisi's official visit to the White House the following April. "He took control of Egypt, and he really took control of it," Trump raved, explaining that Egypt had "tremendous problems" with "terrorists" before Sisi had "wiped them out."

The facts were less flattering. The number of Egyptians killed each year from bombings or shootings by Islamist militants had escalated sharply under Sisi — whether compared with Morsi's sole year in office or with Mubarak's last years.

By "terrorists," Trump presumably meant the Muslim Brothers, whom Sisi had indeed driven underground (although not eradicated). But Trump was clear enough. Sisi was a strongman, just the kind he admired. "We are going to be friends for a long, long period of time," Trump concluded after their White House meeting. The rulers of Saudi Arabia and the United Arab Emirates were just as delighted with Trump as Sisi was.

Donald Trump during his 2016 presidential campaign. Scott Olson/Getty Images

The Saudi royals hosted him in Riyadh, handed him a sword, and danced arm in arm. King Salman, Sisi, and Trump posed together at a Saudi counterterrorism center with their hands on a surreal, glowing white orb of no clear purpose. Prince Mohammed bin Salman, the king's favorite son and dominant adviser, visited the White House and pronounced Trump "a true friend of Muslims."

Why did Trump and the Arab autocrats get along? Trump had chosen General James Mattis as his defense secretary and General Mike Flynn as his first national security adviser, both eager supporters of General Sisi and relentless foes of the Muslim Brotherhood. Ambassador Otaiba of the UAE — Bro- taiba — became a kind of tutor in regional affairs to Jared Kushner, Trump's son-in-law and Middle East adviser. Perhaps Trump and the Arab autocrats both found reasons to overlook his fear of Muslims. I wondered, though, if Trump's fear of Muslims was not an impediment at all. It was part of the bond. Flynn had admired Sisi precisely because he was a "very secular" or "moderate" Muslim. He was one of the good ones, not like the others. In some ways, Sisi and the Arab autocrats appeared to agree that their Muslim citizens were too "backward" to govern themselves.

Prince Mohammed bin Salman of Saudi Arabia and US President Donald Trump. Pool/Getty Images

Egyptians lagged Western Europeans by a "civilizational gap," Sisi told a German magazine in 2015, trying to explain the necessity of the killings at Rabaa. Egyptian friends took the prejudice for granted: Arab dictators like Sisi always appealed to a kind of Western bigotry. The rights that Westerners considered universal at home could not apply to Arabs, because the people and culture were fundamentally different. By 2016, the hope for democratic change in the Arab world felt like a cruel hoax. It was easy to forget that the revolts of 2011 had created a real opening, that for a time Egypt's generals had feared public disapproval, or that Tunisia had completed a peaceful rotation of power. The uprisings had spread more chaos and violence across the region than at any time since the end of World War I. Libya, Yemen, Syria, and Iraq were riven by civil war; Bahrain was held together only by Saudi military force. Struggles for democracy had degenerated into sectarian feuds. Local antagonists were enlisted as pawns in cynical proxy wars between Saudi Arabia and Iran, or between the UAE and Qatar — two rich little American allies in a bizarre family feud.

The leaders of Al Qaeda had worried in 2011 that movements for democracy were upstaging their jihad, offering Muslims what Osama Bin Laden called "half-measures." But the jihadists came roaring back after the turn again to authoritarianism. America was pulled back into war in Iraq for the third time in a quarter century. Refugees from Arab conflicts flooded westward and triggered a nationalist backlash. It was scarcely an exaggeration to say that the tumult across the Arab world had helped to elect Trump as president and to scare Britain out of the European Union.

“I have had a deep appreciation and admiration of your unique personality,” Sisi told Trump. Pool/Getty Images

I happened to be in Washington on the fifth anniversary of the Egyptian uprising, January 25, 2016. Tom Donilon, Obama's national security adviser from the start of the uprising until the weekend of the coup, spoke at a public forum hosted by Politico magazine. What happened to the Arab Spring? was the first question put to him.

"It has been a negative for the people of the Middle East, and it has been a negative for the security of the United States," Donilon said, with I- told-you-so resignation. "You have seen a collapse of the state system in the Muslim Arab world." I thought of Sisi's warnings about "the collapse of the state," and I saw heads nodding around me.

The conclusion that settled over Washington was that the people of the region would have been better off if they had never risen up. Arabs had failed at democracy; maybe they preferred strongmen. We should thank Sisi for restoring order. We should coax him to open the Egyptian economy (Washington's perennial recommendation). And we should keep sending $1.3 billion a year in Apaches and F-16s to fight the Islamic State in the Sinai (as if Sisi's takeover itself had not ignited the insurgency). Political Islam — whether ISIS or the Muslim Brotherhood — was a threat to the West, and Sisi was a bulwark against it. He was a "natural partner," Dennis Ross, the veteran Middle East diplomat who stood with Obama during his last call to Mubarak, argued in his New York Times op-ed, "Islamists Are Not Our Friends."

"The only way to support Egypt's maturation as a country with civil society, with democracy, is to support President el-Sisi," General Mattis argued in April 2016, in a speech at the Center for Strategic and International Stud- ies (which received major funding from the Emiratis). Three years earlier, Mattis had said Egyptians removed Morsi because of his "imperious leadership." Now Mattis said that with Sisi trying "to reduce the amount of negatives about the Muslim religion, I think it's time for us to support him and take our own side in this."

Egyptian President Abdel Fattah al-Sissi, Saudi King Salman, US First Lady Melania Trump and President Donald Trump, visit a new Global Center for Combating Extremist Ideology, in Riyadh, Saudi Arabia. Saudi Press Agency

Six years in Egypt, though, convinced me that the uprisings were hardly the source of the chaos. The old order was crumbling, visibly, from the moment I landed in Cairo, long before the first demonstrator set foot in Tahrir Square. It felt obvious in 2011 — and even clearer in 2018 — that the failure of that Arab state system was the cause of the uprising, not its consequence. The old autocracies were as fragile as their rulers had feared, but that was because their dependence on corruption and coercion had hollowed them out. So nothing could be more naïve than to think that putting the face of a different soldier in front of a refurbished autocracy would yield a more stable result. The thirty months of imperfect steps toward democracy in Egypt had offered at least a chance of an alternative.

Plenty of Egyptians now say that their struggle was doomed from the start. Oddly, living through the utter, calamitous failure of the uprising has convinced me of the opposite: Egyptians have as much potential as any people to fulfill the promises of freedom and democracy that brought Tahrir Square to life. I watched thousands give their lives to build a more just and free Egypt. Their sacrifices are no less inspiring because they were defeated. They labored under the burden of more than six decades of unresolved fears and resentments, against powerful cliques like the judges and generals still deeply invested in the old status quo. And for those thirty months, longer than anyone had a right to expect, Egyptians nonetheless beat back repeated attempts to restore that old order.

Tahrir square. AP

Egyptians elected a president from the Muslim Brotherhood, and the dreaded theocratic takeover did not come to pass. Morsi may have been a second-rate amateur of a president, yet for a time he looked like he might hang on long enough to be voted out of office, like the Islamists of Tunisia. Morsi was not wrong to suspect enmity from the deep state. Nor was he wrong to worry that the Saudis and Emiratis were out to undermine him, or that many in Washington would be glad to see him gone. Morsi was wrong to trust Sisi.

Nor were liberals like ElBaradei wrong to fear that Muslim Brotherhood leaders might be tempted to cling to power. The demonstrators outside Morsi's palace were not wrong to worry that the Interior Ministry was still intact, abusive, and menacing. But ElBaradei and the demonstrators made the same mistake. They trusted Sisi. They lent their credibility to a coup that destroyed the very thing that they said they stood for: the chance to build a liberal democracy. The civilians let their fears divide them, and the generals were ready and waiting.

On the morning of Trump's election, I met my friend Hossam Bahgat for coffee in Zamalek. He was thirty-seven years old but still looked like a graduate student. He was clean- shaven, with close- cropped hair and oval-shaped glasses, and he hauled around a leather satchel of books and newspapers slung over his shoulder.

Fifteen years earlier, at the age of twenty-two, Bahgat had founded what became Egypt's most important human rights organization, the Egyptian Initiative for Personal Rights. He had done more than anyone to document the dark sides of authoritarianism — torture, police abuse, sexism, homophobia, sectarianism, and corruption. To a generation of Western journalists and diplomats, Bahgat was an indispensable resource. Whenever a big shot from the home office came to Cairo, the first thing we all did was to set up a meeting with Bahgat. Then Mubarak fell, the news media opened up, and Bahgat reinvented himself as Egypt's most important investigative journalist. He wrote for and then edited the left-leaning online publication Mada Masr (The Scope of Egypt, though mada can also mean the setting of a precious stone). I thought Bahgat was one of the smartest people I have ever met, and one of the bravest.

He had narrowly evaded arrest at least twice since Sisi took power. In October 2014, he was tipped off that the police were coming for him. He caught the next flight to New York, where he accepted a fellowship at the Columbia School of Journalism. But Bahgat loved Egypt. Also, he hated cold weather. So a year later he convinced himself that Cairo was safe enough to return. Military intelligence called him in for questioning in November 2015 about something he had written. The officers detained him in their headquarters, and as soon as I found out, I wrote an article for the website of the New York Times as quickly as I could. The State Department expressed alarm about the rule of law and freedom of expression. Secretary General Ban Ki-moon of the United Nations issued a personal appeal. And after two nights Bahgat was out. "Mama Amreeka" still had some clout, I thought. But the mukhabarat was only biding its time. In early 2016, prosecutors opened a criminal case against Bahgat for accepting unauthorized foreign contributions to the rights group he had founded. He was banned from travel and his assets were frozen (along with those of several others). A long series of hearings began.

Investigative journalist Hossam Baghat, center, leaves a courtroom at the Cairo Criminal Court after the court postponed a decision on whether to implement an order to freeze his assets over allegations of illegal foreign funding, in Cairo, Egypt Thursday, March 24, 2016. AP

Then Trump won the election. "Now I am definitely going to jail," Bahgat joked to me in a text message that morning. He had no great love for Hillary Clinton; Bahgat preferred Bernie Sanders. But we both knew that Trump had shown no patience for human rights at home, much less in Egypt. He was not about to pressure Sisi to free someone like Bahgat. Bahgat's trial ground on through 2017, and he kept a brave face. He told me that over time he had found something to like about Trump. Bahgat thought: Here was an American president who made his family members top White House advisers. He pushed conspiracy theories, called critics treasonous, and bullied the news media. He lied with impunity. He disdained legal customs and parliamentary process. He fired a top law enforcement official whose investigations threatened him. And Americans on both the left and the right had started speaking of a "deep state" of their own — a permanent government that had either stymied Obama or thwarted Trump, depending on who was talking.

Washington had puzzled about why Egyptians behaved so differently than we did. Bahgat thought we were starting to act a little Egyptian. "America," Bahgat wrote on Twitter in the spring of 2017. "So deliciously third world."

From INTO THE HANDS OF SOLDIERS by David D. Kirkpatrick, published by Viking, an imprint of Penguin Publishing Group, a division of Penguin Random House, LLC. Copyright © 2018 by David D. Kirkpatrick.