Donald Trump campaigned hard on military issues.

He vowed to bring "endless wars" to a close, "rebuild" the fighting forces and compel allies to pay their fair share, saying the U.S. would no longer be "suckers."

That message resonated among voters and helped propel him to the White House in the 2016 election. Among troops, he seemed to enjoy fairly strong support. A Military Times poll showed that 46% had a favorable view of him at the start of his term, 10 points higher than President Barack Obama had in January 2017.

Still, Trump was unable to end those endless wars. He leaves a military that is still fighting and advising in Afghanistan, Syria, Iraq and Yemen, though in smaller numbers.

He provided a significant budget boost, made the troops more ready and created a U.S. Space Force. NATO members did end up paying more for their defense — for many years a source of official Washington grumbling — though there were fractures within the alliance over Trump's abrasive nature and abrupt decisions, such as withdrawing troops from Afghanistan without consulting NATO leaders.

But in the end, several analysts say, what stands out is the damage Trump did to civilian-military relations. He used troops — and senior officers — in clearly political events, at times referring to "my generals." One senior officer, who is not authorized to speak publicly, recalled that in his dealings with Trump, the president was surprised to learn the military is apolitical.

Moreover, Trump brushed aside a military justice system that found service members guilty of war crimes, granting them pardons.

Trump "was constantly undermining civilian-military relations around the bounds of what is acceptable behavior," says Peter Feaver, a Duke University professor who focuses on those relations. "This, combined with the fact that he has a tin ear for all things in the civil-military domain, means that Trump did lots of damage to this crucial pillar of the republic."

Aaron O'Connell agrees. He was a Marine Corps officer who served in Afghanistan and in Obama's National Security Council.

The "biggest thing," says O'Connell, who now teaches at the University of Texas, is Trump's pardons for Navy Chief Petty Officer Edward Gallagher and Army 1st Lt. Clint Lorance. Both were convicted of war crimes by the military.

"They were not close calls on the merits," O'Connell says. "Why get involved with this? It only hurts the military, hurts the rule of law and hurts the image of the U.S. as a law-abiding nation."

Trump also tested civilian-military relations by urging that active-duty troops be used to quell street protests following the killing of George Floyd by Minneapolis police last year.

Defense Secretary Mark Esper strongly and publicly opposed such a move, saying it was a job for local police and possibly the National Guard. Trump soured on Esper after that, and their relationship never survived. Months later, Esper was "terminated" by Trump in a tweet.

"Trump's willingness to use the military against legitimate protests in America [last] year stands out as particularly significant and damaging," says Carter Malkasian, a former senior Defense Department official. "The backlash was thankfully great, so hopefully our institutions have emerged undamaged."

Michael O'Hanlon, a defense analyst at the Brookings Institution, acknowledged he is no "Trump fan," seeing him as "an extremely dangerous commander in chief" and citing his saber rattling and his threatening a war with North Korea.

But O'Hanlon sees Trump's overall legacy as relatively positive.

"The increase in budgets, readiness levels and modernization efforts will be sort of like a 'mini Reagan period,' " O'Hanlon says. "Fifteen years of war and several years of budgetary dysfunction had left things frayed."

Brad Bowman, a defense analyst at the Foundation for Defense of Democracies, credits the Trump administration with prioritizing military research and development with the largest budget increase ever, saying the Pentagon recognized the growing technological prowess of China and Russia as well as the changing character of warfare.

"To its credit," says Bowman, "the Trump administration explicitly shifted the Pentagon's focus to great-power competition," meaning China and Russia, no longer making anti-terrorism efforts a priority. That came through a National Defense Strategy crafted by Trump's first defense secretary, James Mattis.

Mackenzie Eaglen of the American Enterprise Institute says the three-year "Trump bump" defense increases were "significant and helpful, particularly to restoring readiness."

"But not nearly enough to completely rebuild the military," she says, "as he claimed in his State of the Union address [last] year."

Eaglen also says that despite the increases, Trump's souring on those who disagreed with him — including Defense Secretaries Mattis and Esper — was one of the big reasons Trump could not oversee the buildup of the Navy during his tenure, a buildup that would have reflected the focus on Asia and the growing threat from China.

She also faults Trump for using Pentagon money to build his wall on the border with Mexico. Such action, Eaglen says, "sets up the budget to be raided by any future president for any self-declared 'emergency.' "

Todd Harrison, a budget expert at the Center for Strategic and International Studies, echoed those concerns, calling the shift in funds for the wall one of the "worst legacies" of the Trump years.

"I think Congress will need to rethink many of the provisions it routinely puts into law," says Harrison, "that allow the president to reallocate certain types of funding in a crisis without prior approval from Congress."

Despite Trump's talk of building up the military, some analysts say he's overstating his efforts.

"Obama in his first term spent more than [Trump] did," says Larry Korb of the Center for American Progress. Obama spent $3.3 trillion on the military in his first term, Korb points out, compared with $2.9 trillion during Trump's term.

Moreover, Trump's claim of a military that was lagging under Obama was not the case, Korb says. Back in the summer of 2016, retired Gen. David Petraeus and O'Hanlon wrote an opinion piece in the Wall Street Journal titled, " The Myth of a U.S. Military 'Readiness' Crisis," saying there were areas of concern but no crisis.

One retired senior officer who served under three presidents and who asked not to be identified because he still works in government says in the end Trump was someone who in the national security realm was chaotic and transactional, often tweeting policy changes.

Such tweets announced that all troops would be withdrawn from Syria — a decision that angered both U.S. Special Forces on the ground and their Kurdish partners fighting the remnants of the Islamic State. In the end, Trump was convinced by military leaders to keep hundreds of troops to continue the fight — and protect oil fields.

"No one could trust that what he said was true — the old 'your word is your bond' didn't hold true with the president," the retired officer adds.

On Afghanistan, Trump was successful in getting a U.S.-Taliban peace deal that would mean the withdrawal of all American troops by this spring, as long as the Taliban agreed to abide by certain conditions, such as breaking with al-Qaida and not attacking cities. That would mean America's longest war — at 19 years — would come to an end.

"It's hard to see how the February 2020 agreement with the Taliban would have come about without Trump's drive to get out, not to detract from [U.S. negotiator] Ambassador Zalmay Khalilzad's diplomatic skills," says Malkasian, the former Pentagon official.

Korb, of the Center for American Progress, said removing U.S. troops from Afghanistan made sense — but not the way it was handled by the administration.

Trump ordered reductions in U.S. troop levels from 4,500 to 2,500, even though military officials wanted to maintain that higher number into 2021. Military officials privately acknowledged that the Taliban had failed to meet the conditions called for in the agreement, but it appeared Trump was intent on maintaining a campaign pledge to bring the troops home.

Both Afghan officials and NATO allies were caught off guard by the reductions. And when acting Defense Secretary Chris Miller made the troop cut announcement in the Pentagon briefing room, he swiftly left without answering any questions.

Trump's constant policy by tweet and abrupt decisions, with little deliberation among officials and allies, left others to handle the fallout.

"Military and some civilian leaders have been in constant damage control over the last four years," the retired officer says. "The old 'cleanup on aisle 4, then 6, then 8.' "

And in the end, there were signs that those within the military were souring on Trump.

A Military Times poll taken before the election showed that earlier 46% approval rating for Trump dropping by 8 points.

Retired Adm. James Stavridis, the former top officer at NATO, says Trump will have "a very mixed legacy." He was a strong advocate for funding the Pentagon and the Department of Veterans Affairs, but his crude language, his pardoning of war criminals and his sudden removal of troops will be remembered negatively.

"Strategically, the military will remember him as a very political commander in chief who basically wanted to pull back from our overseas commitments and international alliances — an approach not well regarded by many in the force," Stavridis says. "To the degree there was a 'Trump Doctrine,' it seemed to be withdraw and come home."

Copyright 2021 NPR. To see more, visit https://www.npr.org.