WASHINGTON (Reuters) – President Donald Trump picked retired generals for some of his most senior national security posts when he took office and boasts of heavy spending on the U.S. military that he asserts is unmatched in history.

He has made getting U.S. allies to increase their own military spending a cornerstone of foreign policy along with a commitment to walk away from “ridiculous endless wars” in the Middle East that have killed thousands of U.S. troops.

But the Republican president has also ridiculed his top generals, ignoring their advice on some key issues and questioning their intelligence, courage and commitment to their soldiers.

Critics say Trump has used the military as a prop and purposefully undermined Pentagon efforts to remain apolitical.

Related: The case for rethinking the politicization of the military

A businessman and former reality TV star, Trump in 2016 won the presidency, his first public office, while challenging the establishment, including even fellow Republicans. He often, even publicly, rejects advice, most recently that of his health experts on the coronavirus, without losing much ground among his supporters. It remains to be seen whether this dismissive approach, including with his generals, leads to victory in his November election bid for a second four-year term.

This month Trump, who never served in the military, had to battle a report in The Atlantic that on a 2018 visit to France he referred to American soldiers killed during World War One as “losers” and “suckers.”

A review of Trump’s speeches and tweets throughout his presidency and interviews with aides and military officials show a contradictory and steadily deteriorating relationship, with Trump sometimes gushing with praise for his generals and other times portraying them as incompetent.

Trump likes to say he pays more attention to the rank-and-file.

“I learn more sometimes from soldiers, what’s going on, than I do from generals. I do. I hate to say it. I tell the generals all the time,” Trump told a convention of conservatives in 2019.

When he was accused of disparaging service members this month, Trump returned to the same theme and denied any wrongdoing.

“I'm not saying the military's in love with me. The soldiers are,” he told reporters. “The top people in the Pentagon probably aren’t because they want to do nothing but fight wars so all of those wonderful companies that make the bombs and make the planes and make everything else stay happy.”

Related: Trump accuses Pentagon leaders of wanting to 'fight wars' to make defense companies rich

Some current and former military officials say that Trump started out with extravagant praise for his generals but grew irritated when their advice ran against his wishes, frustrated by the wars he inherited and uncomfortable with an apolitical military leadership he sometimes sees as disloyal.

They complain he flouts norms of behavior in his open pursuit of political support among U.S. troops, who are meant to be loyal to the U.S. Constitution – not any party or political movement.

“Our civil-military norms can only take so much pressure for so much time,” one military official said, speaking to Reuters on condition of anonymity. “You're already seeing cracks. You're already seeing politicization of the uniform.”

A former defense official who served under Trump and spoke on condition of anonymity said the problem boils down to Trump's views on loyalty. “He views it as: ‘Are they on my side or not? Are they with me or against me?’”

Despite painting himself as a defender of the country's warriors, Trump has seen his support among military personnel fall, according to opinion polls by Military Times.

At the start of his presidency, 46 percent had a favorable view and 37 percent were unfavorable. The most recent survey in July and August showed those numbers flipping to 38 percent and 50 percent, respectively.

White House spokesman Judd Deere said Trump has demonstrated his commitment to the U.S. military and holds U.S. troops and their families in the highest regard.

“And he is awed by our soldiers’ bravery and courage to protect this country, our values, and our flag,” Deere said.

Church walk

United States photo

Military chiefs briefly stumbled into America's political divide in June, when senior Pentagon officials accompanied Trump as he walked to a church near the White House to lift a Bible for a photo. This was shortly after law enforcement officers backed by National Guard troops used tear-inducing chemicals and rubber bullets to clear the area of peaceful protesters.

Adam DeMarco, a major in the National Guard, took the rare step of appearing at a congressional hearing to voice concern over the crackdown.

“The events I witnessed at Lafayette Square on the evening of June 1 were deeply disturbing to me and to fellow National Guardsmen,” DeMarco said.

Trump's threat to militarize the response to U.S. protests prompted some retired four-star generals to issue statements condemning it. The military is meant to protect Americans' right to peaceful protest, they said.

Retired Marine general James Mattis, who was Trump’s defense secretary for the first two years of his presidency, was withering in his response.

“Donald Trump is the first president in my lifetime who does not try to unite the American people — does not even pretend to try,” he wrote. “Instead he tries to divide us. We are witnessing the consequences of three years of this deliberate effort.”

U.S. Army General Mark Milley, chairman of the Joint Chiefs of Staff, later acknowledged accompanying Trump that day had been a mistake, having created a “perception of the military involved in domestic politics.”

Mattis, from admiration to insults

United States photo

Before taking office, Trump met with Mattis at Bedminster in December 2016 and brought him before the media, taking great delight in the general’s “Mad Dog” nickname, and pronounced him right out of central casting.

But he soured on the general and others for not bending to his will on a range of issues, at home and abroad. Mattis disagreed with Trump's berating of U.S. allies, his disparagement of NATO and his abrupt pullout in Syria, which went against the advice of his military.

Trump has since branded Mattis “the world's most overrated general.”

The first signs of troubled relationships with the generals came early in his presidency.

In the summer of 2017, Trump was in the Situation Room talking about U.S. troop levels in Afghanistan with Mattis, then-national security adviser H.R. McMaster – an Army general – and then-Secretary of State Rex Tillerson and others.

The generals had a troop increase request and “thought they were going to stick it up under Trump’s nose and he was going to sign it,” a former senior administration official told Reuters.

Trump raised all sorts of questions about the request. A meeting due to last 20 minutes went on for two hours.

“He just ripped them, the generals, everybody. ‘Why are we doing this, when can we get out, what does victory look like?’ It was really uncomfortable,” the former official said.

After the meeting broke up, Trump asked them for “real options.”

Although Trump initially reversed troop withdrawals in Afghanistan ordered by his White House predecessor, Barack Obama, he ends his term in office with plans to slash them to 4,000 this year and withdraw them completely next year, if a peace deal succeeds.

McMaster, who lasted just over a year as Trump’s national security adviser before being ousted, has sharply criticized Trump’s Afghanistan policy, accusing him of partnering with the Taliban against the U.S.-backed government in Kabul.

Pentagon leaders see alliances as essential both to U.S. influence overseas and security at home. They voice alarm at Trump’s antagonistic approach to allies such as Germany and South Korea even as he boasts of his good relationships with the leaders of China, Russia and North Korea.

Risa Brooks, a professor at Marquette University, said military leaders felt Obama had micromanaged Pentagon issues and some were initially pleased to see Trump’s approach.

“But now I think we're in a whole other level. I think what is going on is that you see some of the stuff Trump is doing is a challenge to the core organizational interests and integrity of the military,” she said.

One clear example was Trump's intervention in the case of Special Operations Chief Edward Gallagher, who was convicted of posing with the corpse of an Islamic State detainee.

Trump, who saw himself as a champion of troops being mistreated by top brass, reversed the Navy's demotion of Gallagher, and the Navy secretary was later fired.

“I will always stick up for our great fighters,” Trump told a Florida rally in November 2019.

Related: US civil-military relations: a flawed deal in desperate need of repair