Expected to attend are 37 heads of state and at least six prime ministers, said Osama Nugali, a spokesman for the Saudi Foreign Ministry.

Among the invitees is President Omar Hassan al-Bashir of Sudan, who has been indicted by the International Criminal Court for crimes including genocide, although it remains unclear whether he will attend or, if he does, whether he will meet Mr. Trump.

“He is invited definitely because it is an Arab and Muslim country,” Mr. Nugali said.

Also reported by local news organizations to be attending are President Fuad Masum of Iraq, President Abdel Fattah el-Sisi of Egypt, President Ashraf Ghani of Afghanistan and Prime Minister Nawaz Sharif of Pakistan.

Not on the guest list are Iran, the Saudis’ regional nemesis, and Syria, whose president, Bashar al-Assad, is at war with rebels who have received support from the United States, Saudi Arabia and other countries whose representatives will be in Riyadh.

Mr. Trump and King Salman will also inaugurate the Global Center for Combating Extremist Ideology, where Mr. Trump is to give a speech about Islam. The American president, a prolific — and often contentious — user of Twitter, will also deliver the keynote address at a conference about social media, under the auspices of Deputy Crown Prince Mohammed bin Salman, the king’s powerful son.

Elsewhere in the city, there is to be an international counterterrorism conference, a forum for chief executives, an art exhibition inside the Royal Court and a concert featuring the American country musician Toby Keith. (In a kingdom where alcohol is banned, he is unlikely to entertain the all-male crowd with his song “Beer for My Horses.”)

“Historic Summit. Brighter Future,” an official website for Mr. Trump’s visit declares.

The exuberant reception reflects the sharp contrast with how Persian Gulf leaders perceived Mr. Obama and his policies. He angered the Saudis for what they saw as his abandonment of President Hosni Mubarak of Egypt, a longtime American ally, during the Arab Spring protests; his hesitation to intervene directly in the Syria conflict; and his pursuit of a nuclear deal with Iran.