How Trump's Middle East trip may have alienated a key counterterror ally Trump's trip may have alienated Iraq, experts say.

 -- President Trump said Thursday that his first trip overseas has given him “renewed hope that nations of many faiths can unite to defeat terrorism, a common threat to all of humanity.” But his time in the Middle East may have done more to deepen one of the region's main religious divides and alienate a key ally in that fight, experts told ABC News.

The president chose Saudi Arabia for the first stop on his first overseas trip as president and praised King Salman for his stance against extremism -- particularly with respect to Iran. But a weekend spent blasting Iran -- a predominantly Shiite country -- from the halls of its longtime Sunni adversary could risk alienating America’s most important ally in the fight against ISIS: Iraq, Middle East experts said.

As President Trump and leaders from dozens of Muslim countries gathered in the King Abdulaziz Conference Center in Saudi Arabia Sunday, there was one critical Middle Eastern leader missing from their family photo -- because he wasn’t invited -- sources tell ABC News.

Iraqi Prime Minister Haider al Abadi was home in Baghdad, where his administration is leading that fight against the terror group ISIS that has upended their country.

Instead of Abadi, who is a Shiite Muslim, Saudi Arabia invited Fuad Masum, Iraq’s Sunni Kurdish president, largely a ceremonial position. That kind of snub for Abadi, seemingly along sectarian lines, was just one of a handful of perceived slights for Iraq at a summit that was meant to bring Muslims together against terrorism, experts say.

Critics say that the summit's targeting of Iran as a source of extremism and its sidelining of a prominent Shiite leader could drive the Iraqi government further into Iran’s arms at a time when the U.S. needs a strong partner there.

“It was another example of Saudi dismissal of Iraq as a potential ally,” said James Jeffrey, the former U.S. ambassador to Iraq. “Saudi Arabia writes off Iraq as a Iranian vassal ... and this undercuts U.S. efforts.”

“Having Iraq's leadership snubbed by the Saudis and not having Abadi there is truly unfortunate. It's a real missed opportunity,” said Ilan Goldenberg, Director of the Middle East Security Program at the Center for a New American Security and a former State Department and Pentagon official.

It also reveals a new U.S. administration that is either inexperienced or missed the nuances of a complicated region, according to some experts.

“This whole incident shows what happens with a new inexperienced team with much of the State Department mid-ranks empty,” added Jeffrey. “Those people are supposed to foresee such problems and counter it. Didn't happen.”

The cold shoulder for Abadi was not the only insult perceived by the Iraqis. When President Masud arrived, he was greeted at the airport not by any high-ranking Saudi officials, but the vice emir of the local province Riyadh. It was a humiliating reception, according to Iraqi press.

The summit also appeared to downplay Iraq’s role in the campaign against ISIS. King Salman did not mention Iraq once in his speech and Trump did not praise the Iraqi army’s efforts on the front lines, only giving a nod to the “American troops [who] are supporting Kurds, Sunnis and Shias fighting together for their homeland.”

President Masum wasn’t given a speaking slot at all, although his office posted the text of a speech he had ready on their website.

“ISIS have killed the Sunnis, Shiites, Christians, Yazidis, Arabs, Kurds, Turkmen, Shabaks and others without any discrimination, and its ugly crimes included all the Iraqi components,” he would have told the summit, had he been able to.

A senior administration official praised the summit, saying, “Donald Trump united the entire Muslim world in a way that it really hasn’t been in many years.”

But by trying to make Iran the common enemy in Riyadh, the summit put Iraq in an awkward position. Once sworn enemies who fought a brutal eight-year war, Iran and Iraq have had close ties since Sunni strongman Saddam Hussein was deposed by the U.S. in 2003. After years of his oppressive rule, Iraq’s majority Shiites took power and aligned with Iran.

Iraq's Sunni minority began to suffer persecution and mistreatment under the new Shiite leadership, including abuses by the new Shiite-majority Iraqi army and the Shiite militia groups backed by Iran. That sense of alienation and abuse helped to drive the rise of ISIS, a Sunni terrorist group that swept across traditionally Sunni areas, experts say.

While a common enemy in ISIS has united the country for now, new pressure on the country's sectarian fault lines could ignite tensions within Iraq just as ISIS’s defeat in Mosul appears imminent, especially with Shiite militias and Shiite-majority armed forces emboldened by their victories on the battlefield.

But because of that complex relationship, Abadi’s absence from the summit could have also been a blessing for him, says former U.S. ambassador to Iraq Ryan Crocker.

“I’d imagine Abadi was grateful not to be invited,” said Crocker. “As he tries to juggle a relationship with Saudi Arabia at a time when the Saudis are in maximum overdrive against the Iranians, I think he would be pleased and relieved that he wasn’t put on the spot like that.”

Crocker says the Iraqi officials he's spoken with aren't acting like it's a snub and have praised what they've seen from Trump so far.

Despite the tension, the Saudis and the Iraqis have made efforts to build relationships in recent months. Saudi Foreign Minister Adel al Jubeir traveled to Baghdad in February, the first such visit in 27 years, and the Iraqis say they are working with the Saudis on a visit by Abadi to the Kingdom soon, according to Crocker, the first in more than a decade.

“There is an opening for a very good neighborly relationship,” Abadai said of the Iraqi-Saudi relationship at the U.S. Institute of Peace in Washington in March. “Our Saudi friends used to think that Iraq is under the control of our Iranian neighbors, but we are not. Iraq is governed by Iraqis, and they saw for themselves” with Jubeir's visit.

Still, suspicions run deep in Riyadh, where officials watch Iran’s influence in the region with great concern.

“The shabby treatment the Iraqis feel they received has more to do with how the Saudis see the Iraqi government and its ties to Iran,” said Aaron David Miller, vice president and distinguished scholar at the Wilson Center who was a Middle East negotiator under presidents of both parties.

“It's less relevant to Riyadh whether Iraq is fighting ISIS than it is Baghdad's unwillingness and inability to buck Iran.”

But experts say this week's gathering may not have given Baghdad much impetus to leave Tehran's orbit.

“A critical element of U.S. strategy for countering Iran involves encouraging closer ties between Iraq and the Gulf States in order to pull Baghdad away from Tehran,” said Goldenberg.

Bringing Iraq into alignment with its Gulf allies remains a top priority for the U.S., especially for a new administration that has put Iran "on notice."

ABC News's Mazin Faiq contributed to this report.