President Trump, first lady Melania Trump, King Salman bin Abdul Aziz of Saudi Arabia, center, and Egyptian President Abdel Fatah al-Sissi appear Sunday at the opening of the World Center for Countering Extremist Thought in Riyadh. (Saudi Press Agency/European Pressphoto Agency)

He talked about Islam. He thundered against extremism. But after President Trump’s hotly anticipated speech in Saudi Arabia was over Sunday, many in the Arab world latched on to another theme from his address, one that explained why a leader who had shown hostility toward Muslims would travel to the religion’s birthplace.

The answer? The bottom line.

“This summit has nothing to do with security. It’s all about business,” said Khalid Kilany, a 28-year-old engineer in Cairo, reflecting the views of an Arab public that had taken note of the vast sums — in arms sales and other business deals — that were announced during Trump’s visit.

The trip had delivered “more power to the Saudi royal family. More money to the U.S. Case closed,” Kilany said.

There was broad agreement that the president’s visit signaled a change in tone toward the region, and from Trump’s own previously strident anti-Muslim rhetoric. It was well-received among the assortment of monarchs and leaders who sat in the audience Sunday, under crystal chandeliers, grateful for a show of solidarity from an American president as well as his promise not to meddle in their affairs.

Beyond the gilded ballroom, there was also plenty of skepticism about the close U.S. embrace of Saudi Arabia, a country with its own troubled legacy of extremism that made it an awkward stage for a speech about the dangers of radicalism.

As he arrived in his Humvee on Sunday in the Iraqi city of Mosul, where mortars fell nearby, Master Sgt. Dhu-Alfuqar Ali, a member of Iraq’s elite counterterrorism unit, said that Trump should not have delivered the speech in Saudi Arabia, “where they are supporting terrorism.”

“He should have come here, to where the actual war is taking place,” he said, speaking of a place that, by a country mile, had suffered most grievously from extremist groups such as the Islamic State.  

Views were different in the Persian Gulf region, where leaders had complained resentfully about the Obama administration’s neglect and its occasional scolding about human rights abuses, as well as its outreach to Iran.  

When President Barack Obama delivered his address to the “Muslim world” in Cairo in June 2009, it contained a passage about democracy that surely rankled Arab leaders at the time and may have haunted them, nearly two years later, when they faced protests from their own restive populations.

There was no scolding Sunday. Trump “spoke respectfully about Muslims and the GCC countries,” said Abdelkhaleq Abdulla, a professor of political science from the United Arab Emirates, referring to states that belong to the Gulf Cooperation Council.

“Very candid, very articulate,” said Abdulla, who was especially heartened that Trump had singled out Iran for criticism. He worried, though, that Trump’s mercurial personality might mean a sudden change in course. And Trump’s refusal to mention the lack of freedom in the Arab world was a “valid criticism,” he said.

“This is the Trump America. It is interest-based, not value-based,” Abdulla said. “Until we go to the post-ISIS era, no one is in the mood to talk about anything else,” he said, using an acronym for the Islamic State.

Khlood Mohammed, 25, a Saudi student, said she was pleasantly surprised, particularly by Trump’s acknowledgment of Saudi efforts to fight terrorism. But Madawi al-Rasheed, a visiting professor at the Middle East Center of the London School of Economics, said the president had chosen the kingdom for a different reason.

“Trump only recognizes regimes who can pay for a wide range of US services, military, economic and otherwise,” she wrote in the online Middle East Eye. “He believes in their pockets, rather than their faith.”  

For better or worse, Trump’s visit — the pageantry, the personalities and the bizarre contradictions — captivated the region. In Libya, Ahmed Tabawi Wardako, a southern tribal leader, managed to catch the address.

“I am not a huge fan of Trump, but his speech spoke to the heart of many Muslims,” he said, suggesting it revealed the U.S. president’s true intentions. “He didn’t want us to come to America, but he ended up coming to us,” Wardako said, referring to Trump’s inclusion of Libya on a list of Muslim-majority nations banned from travel to the United States, as well as to his anti-Muslim statements.

“I think he said all that just to fool the American voters. Trump is with the Muslims now,” he said.

Many others, though, were left scrambling to respond to Trump’s speech — his most expansive comments yet on Middle East policy — or to divine its meaning.

Fawzi Barhoum, a spokesman for Hamas, a Palestinian militant group that governs the Gaza Strip, said the group rejected Trump’s association of the group with the Islamic State and al-Qaeda. “Hamas is a national liberation movement legally defending the Palestinian people’s rights,” he said. The speech, he added, “ruins the reputation of the Palestinian resistance.”

There was also anger in Iran, singled out for criticism by Trump, with no mention of the Iranian presidential election last week that turned out tens of millions of voters and dealt a blow to the country’s hard-liners.

The riposte came from Javad Zarif, Iran’s foreign minister. “Fresh from real elections — attacked by @POTUS in that bastion of democracy & moderation,” he wrote on Twitter, in a dig at Saudi Arabia, Iran’s regional rival. “Foreign Policy or simply milking [Saudi Arabia] of $480B?” he added.

In Syria, activists in rebel-held territory said they gathered around a friend’s laptop to watch Trump’s speech, hoping for clues about his strategy to help end the civil war. Youssef al-Masri, an electrician from the Aleppo countryside, said the speech hit the right notes but left the room confused. “He is right to condemn the radicals who have destroyed our country. I wonder if he really sees people like us, who need his help, as any different to the radicals,” he said, citing the refugee ban and increasing reports of civilian casualties in U.S. bombing raids.

Then there was Yemen, site of one of the Arab world’s bloodiest and most tragic armed conflicts, which Trump referred to only obliquely, as a theater of influence for Iran — even though his Saudi hosts lead an Arab coalition fighting there and play a predominant role in the continuation of the war.

But the Saudis “definitely want a freer hand” in the conflict, said Farea al-Muslimi, head of the ­Beirut-based Sanaa Center for Strategic Studies, making it unlikely that Trump would have spoken out forcefully for a settlement.

The president “had three priorities” in Saudi Arabia, Muslimi said. “Deals, deals and deals.” 

Mahfouz reported from Cairo. Mustafa Salim and Thomas Gibbons-Neff in Mosul; Sheikha Aldosary in Riyadh, Saudi Arabia; Louisa Loveluck and Suzan Haidamous in Beirut; Heba Habib and Erin Cunningham in Istanbul; Sufian Taha and Ruth Eglash in Jerusalem; Hazem Balousha in Gaza; and Sudarsan Raghavan in Tripoli, Libya, contributed to this report.