Calling terrorists "the foot soldiers of evil," the president added, "If we do not stand in uniform condemnation of this killing, then we not only will be judged by our people, not only will be judged by history, but we will be judged by God."

In Riyadh, Trump said, "This is not a battle between different faiths, different sects, or different civilizations. This is a battle between barbaric criminals who seek to obliterate human life, and decent people of all religions who seek to protect it."

The speech during the initial stop of the president's first foreign trip was a stark contrast to his previous comments on Islam. As a candidate, Trump frequently criticized the religion, saying, "I think Islam hates us" and "there's a tremendous hatred there."

"Drive them out!" Trump said of terrorists to dozens of Arab leaders who attended his remarks. "Of your places of worship, drive them out of your communities, drive them out of your Holy Land, and drive them out of this Earth!"

RIYADH, Saudi Arabia — President Donald Trump offered a message of unity Sunday as he called on the Arab world to confront extremism during a highly anticipated speech in the birthplace of Islam.

The U.S.'s Middle Eastern allies have often complained about America's focus on human rights, a stance Trump also seemed keen to make a break from.

"America is a sovereign nation and our first priority is always the safety and security of our citizens," the president said. "We are not here to lecture — we are not here to tell other people how to live, what to do, who to be, or how to worship. Instead, we are here to offer partnership — based on shared interests and values — to pursue a better future for us all."

Introducing Trump, Saudi Arabia's King Salman spoke of the need "to stand united to fight the forces of evil and extremism."

"There is no honor in committing murder," Salman said, adding that Islam is "the religion of peace and tolerance."

In his address, Trump defined the struggle against extremism as "a battle between good and evil."

"Barbarism will deliver you no glory — piety to evil will bring you no dignity," the president said. "If you choose the path of terror, your life will be empty, your life will be brief, and your soul will be condemned."

Trump also offered a firm rebuke of Iran — a notable departure from the Obama administration's overtures to the country which had caused a chill in relations with the Saudi government.

Calling out Iranian leaders for training terrorists and "spreading destruction and chaos across the region," Trump, who has called for ripping up the nuclear deal with Iran, implored all nations to "work together to isolate" Tehran until the regime is "willing to be a partner for peace."

"Pray for the day when the Iranian people have the just and righteous government they so richly deserve," he said.

Trump also included a brief reference to his hope for peace between Israel and the Palestinians — a deal he has repeatedly said he hopes to broker during his time in office.

In the speech at the King Abdul Aziz Conference Center, Trump did not use the phrase "radical Islamic terror" — one he uttered repeatedly on the campaign trail, and lambasted his predecessor for not saying. The president did refer to "confronting the crisis of Islamic extremism and the Islamists and Islamic terror of all kinds."

Trump called on countries in the region to do the hard work themselves and not to expect the U.S. to fight terror for them.

"The nations of the Middle East cannot wait for American power to crush this enemy for them. The nations of the Middle East will have to decide what kind of future they want for themselves, for their countries, and for their children," Trump said. "Muslim-majority countries must take the lead in combating radicalization."

Trump said he hoped the gathering of the region's leaders in Riyadh would mark the beginning of the end of terrorism and the start of peace in the Middle East.

"This region should not be a place that refugees flee, but to which newcomers flock,'' the president said.

His presidential campaign was rife with anti-Muslim comments and promises, including his support for surveillance of mosques in the U.S. and for a "total and complete shutdown of Muslims entering the United States until our country's representatives can figure out what is going on."

As president, Trump made good on a version of that promise by signing a travel ban that has been stalled in the courts but which would have temporarily barred entry to those from a handful of Muslim-majority countries, although not Saudi Arabia.

On Saturday, Trump received a royal greeting after touching down in the country. The pomp and pageantry included a signing ceremony for a military arms deal to Saudi Arabia, worth $110 billion effective immediately and up to $350 billion over 10 years, and ended with a boisterous banquet filled with music and dancing.

"That was a tremendous day. Tremendous investments in the United States," Trump told reporters Saturday. "Hundreds of billions of dollars of investments into the United States and jobs, jobs, jobs."

Earlier Sunday before his speech, Trump held meetings with other regional leaders during which he touted "lots of beautiful military equipment" that U.S. workers manufacture.