WASHINGTON — The three largest U.S. airlines presumed that President Donald Trump would take their side in a ferocious, yearslong dispute with Persian Gulf-based airlines — if they could just get his attention.

They got his attention, by way of TV ads the president saw on Fox News. But when Trump finally gathered executives from both sides of the dispute this month in the Oval Office for a heated, "Apprentice"-worthy showdown, he ultimately sided against them.

During an hour-long session, the president ribbed American Airlines CEO Doug Parker over his company’s flagging stock price, asking why it’s so low at a time when the stock market is surging. He scolded Delta Airlines, whose CEO Ed Bastian did not attend, for buying billions in planes from the European firm Airbus while Qatar Airways is buying its jets from Chicago-based Boeing Co.

And he repeatedly harped on Bastian’s absence, questioning how he could be a no-show after his airline — more than any other — had been fanning the flames of the fight.

“The president kept going back to it,” one person who attended the meeting told NBC News. “There was a lot of yelling.”

The meeting was a stark illustration of the president’s freewheeling decision-making style, particularly in areas like U.S. business where he is most confident in his own instincts.

It was also a steep blow to Peter Navarro, Trump’s trade adviser, who found himself on the losing end of a tug of war with national security adviser John Bolton, National Economic Council Director Larry Kudlow and others in Trump’s White House.

This account draws on interviews with 10 individuals, including senior Trump administration officials, airline officials, congressional aides and others who attended or were briefed on the unusual July 18 meeting.

Those individuals, who spoke anonymously because the meeting was intended to be kept private, said nobody knew what the president would do when he sat the CEOs or their representatives from both sides of the dispute down in front of the Oval Office's Resolute desk and asked them one by one to make their case.

For more than four years, the “Big Three” U.S. carriers — American, Delta and United Airlines — have been waging a bitter battle with Qatar Airways and two Emirati airlines over flights between the U.S. and the lucrative European market. The U.S. carriers argue that the Mideast airlines are heavily government-subsidized and are undercutting them by offering below-market fares on flights that never stop in the Middle East.

Most recently, they’ve turned their focus to Air Italy, which added new flights between Milan and the U.S. after Qatar Airways bought a 49 percent stake. The U.S. carriers say it’s a scheme to circumvent restrictions in the U.S.-Qatar “Open Skies” agreement on civil aviation.

Navarro, Trump’s hard-charging trade adviser known for his staunch protectionist views, has kept the issue alive in the White House after overseeing agreements last year to resolve previous grievances by the U.S. airlines, several administration officials said.

But as the Qataris and the U.S. airlines clashed anew this year over Air Italy, Navarro’s campaign thrust him into conflict with the rest of the White House. It drew the attention of Bolton, who enlisted Kudlow and other agencies to wrest back oversight of the issue from Navarro, people familiar with his efforts said.

Navarro declined to comment for this article.

Qatar, though criticized by Trump early in his administration, is a key U.S. partner in the Middle East seen as critical to Trump’s efforts to counter Iran. It hosts roughly 10,000 U.S. troops at al-Udeid Air Base in Doha, enabling the U.S. military to mount operations from Iraq and Syria to Afghanistan.

There are economic reasons, too, for the administration to avoid tipping the scales in the Open Skies fight. Major cargo carriers like FedEx are on the opposite side of the big passenger carriers, as are smaller airlines like JetBlue and Atlas Air that are working to compete with Delta, United and American.

The most recent skirmish came to a head in June around the time that Trump hosted Qatar’s Emir Sheikh Tamim bin Hamad Al Thani for a White House visit. The Qatar Airways CEO, Akbar al Baker, came with him, even joining Trump for dinner in the marbled Cash Room at the Treasury Department.

The big U.S. airlines saw it as an opportunity to engage Trump directly. While Navarro worked to put it on Trump’s radar, a lobby group representing the Big Three airlines was airing ads on Fox News, including on "Fox & Friends," the morning show that Trump is known to faithfully watch.

An airline industry official said their belief was that if Trump got involved, his protectionist tendencies and desire to prop up U.S. job-creators would make him inclined to take the side of the big U.S. airlines.

But the Qataris came with their own jobs-and-economy argument: the purchase of five 777 jets from Boeing, worth $1.8 billion at list prices, along with GE engines. The deal was consummated in a signing ceremony in the Roosevelt Room, with Trump presiding.

The U.S. airlines requested and were granted a meeting a week later with Trump — but not alone. Al Baker was invited to return a week later from Doha and join the FedEx, JetBlue and Atlas Air CEOs to duke it out in the Oval Office with the Big Three.

“We said, ‘Bring it on,’” said one person involved on the side of the big U.S. carriers.

The airlines were told not to tell the media or others about the meeting. But Vice President Mike Pence’s office accidentally listed it on his public schedule.

With the airline CEOs seated around Trump’s desk, his top aides listened from the nearby couches: Bolton, Navarro, Kudlow and acting chief of staff Mick Mulvaney. Sen. Jim Risch, R-Idaho, who chairs the Senate Foreign Relations Committee, and new White House press secretary Stephanie Grisham were also there, people in the meeting said. Grisham did not respond to a request for comment.

“I’ve been seeing all these ads — what’s up with these ads?” the president said, according to two people who were in the room.

The meeting quickly turned to confrontation. Al Baker, the Qatar Airways CEO, called the American and United CEOs “liars.” Trump ribbed him back, telling al Baker he takes money from the Qatari government.

FedEx CEO Fred Smith rattled off statistics about how many jobs his industry creates in the U.S. and warned of dire economic harm if the administration were to intervene to help the big passenger airlines.

Trump kept bringing up the absence of Bastian, the Delta CEO. A Delta spokesman said Bastian was on “previously scheduled travel” that couldn’t be adjusted, but declined to tell NBC News where he was.

Although there’s an obscure complaint process at the Transportation Department to resolve allegations of unfair practices by foreign airlines, the big U.S. airlines for years had resisted it. The process is lengthy and doesn’t address allegations of impending harm, only harm that’s already occurred.

And the Transportation Department — wary of having to pick winners and losers among the big airlines and the cargo carriers — has declined to initiate the process itself and previously discouraged the airlines from applying, industry and U.S. officials said.

Still, as the Oval Office meeting wrapped up, Trump told the airlines that if they wanted to keep pleading their case, the Transportation Department was the place to do it.

After emerging from the West Wing, all sides rushed to put a positive spin on the meeting.

United CEO Oscar Munoz said United looked forward to “continuing to work with the administration” on the issue, while Parker from American said he’d “asked President Trump personally to do everything he can to stand up for American workers and ensure that all airlines are playing by the rules.” The Partnership for Open & Fair Skies, which represents the Big Three airlines, called it “productive” and said Trump “shares our concerns.”

FedEx declined to comment on the meeting. Qatar Airways and the Transportation Department didn’t respond to requests for comment.

The big U.S. airlines have maintained that despite failing to secure intervention by the president, they’re continuing the fight, including taking a new look at the Transportation Department process.

Yet in an ominous sign for that effort, career officials at the Transportation Department previously ran an internal analysis of what would happen if the airlines did pursue a complaint through that process, and determined it would almost certainly be dismissed, several people familiar with that assessment said.

“They’re going to lose the complaint,” one Trump administration official said. “And everybody knows that.”