WASHINGTON — Donald Trump is sparking fears among those who understand the inner workings of the Pentagon that he would convert the nonpartisan U.S. military into the muscular arm of his political agenda as he makes comments about dictatorship and devalues the checks and balances that underpin the nation’s two-century-old democracy.

A circle of appointees independent of Trump’s political operation steered him away from ideas that would have pushed the limits of presidential power in his last term, according to books they’ve written and testimony given to Congress. Most were gone by the end. In a new term, many former officials worry that Trump would instead surround himself with loyalists unwilling to say no.

Trump has raised fresh questions about his intentions if he regains power by putting forward a legal theory that a president would be free to do nearly anything with impunity — including assassinate political rivals — so long as Congress can’t muster the votes to impeach him and throw him out of office.

Now, bracing for Trump’s potential return, a loose-knit network of public interest groups and lawmakers is quietly devising plans to try to foil any efforts to expand presidential power, which could include pressuring the military to cater to his political needs.

Those taking part in the effort told NBC News they are studying Trump’s past actions and 2024 policy positions so that they will be ready if he wins in November. That involves preparing to take legal action and send letters to Trump appointees spelling out consequences they’d face if they undermine constitutional norms.

“We’re already starting to put together a team to think through the most damaging types of things that he [Trump] might do so that we’re ready to bring lawsuits if we have to,” said Mary McCord, executive director of the Institution for Constitutional Advocacy and Protection at Georgetown Law.

Part of the aim is to identify like-minded organizations and create a coalition to challenge Trump from day one, those taking part in the discussions said. Some participants are combing through policy papers being crafted for a future conservative administration. They’re also watching the interviews that Trump allies are giving to the press for clues to how a Trump sequel would look.

Other participants include Democracy Forward, an organization that took the Trump administration to court more than 100 times during his administration, and Protect Democracy, an anti-authoritarian group.

“We are preparing for litigation and preparing to use every tool in the toolbox that our democracy provides to provide the American people an ability to fight back,” said Skye Perryman, president of Democracy Forward. “We believe this is an existential moment for American democracy and it’s incumbent on everybody to do their part.”

America’s commander-in-chief has vast powers at his disposal — some well-known, others not so much. Some lawmakers and pro-democracy advocates worry there may be nothing stopping a president from mobilizing the military to intervene in elections, police American streets or quash domestic protests.

Wary of Trump’s staying power — he is running about even with President Joe Biden in the polls — Democratic lawmakers already known to be adversarial to Trump are working on a parallel track.

Among the least-understood tools available to a president is the Insurrection Act. Vaguely worded, it gives a president considerable discretion in deciding what constitutes an uprising and when it is OK to deploy active-duty military in response, experts say.

Some lawmakers on Capitol Hill worry that Trump might invoke the act to involve the armed forces in the face of domestic protests or if the midterm elections don’t go his way.

Sen. Richard Blumenthal, D-Conn., is crafting a bill that would clarify the act and give Congress and the courts some say in its use. Its chances of passage are slim given that Republicans control the House and are largely loyal to Trump.

“There are an array of horrors that could result from Donald Trump’s unrestricted use of the Insurrection Act,” Blumenthal said in an interview. “A malignantly motivated president could use it in a vast variety of dictatorial ways unless at some point the military itself resisted what they deemed to be an unlawful order. But that places a very heavy burden on the military.”

Trump’s vow to seek “retribution” on behalf of those he says have been “wronged” and “betrayed” has sparked fears that he would use presidential powers more broadly as a cudgel against political foes. Compounding the anxiety, he remarked at a Fox News town hall last month that he would be a “dictator” — though only on his first day in office for the purposes of closing the border and drilling for oil. He later posted on his social media site that he had made that remark “in a joking manner.” More recently, Trump told a Fox News town hall in Iowa that “I’m not going to have time for retribution.”

Detractors aren’t buying it.

“He’s a clear and present danger to our democracy,” said William Cohen, a former Republican senator from Maine and defense secretary in the Clinton administration who is not involved in the loose-knit network. “His support is solid. And I don’t think people understand what living in a dictatorship would mean.”

Sent a list of questions about the fears recounted in this article, Trump’s campaign did not respond.

‘The same lessons Lincoln learned’

Trump’s legal troubles offer new insights into his vision of a presidency that has shed restraints. Not even bribery or murder could land a president in jail so long as Congress didn’t first impeach and convict him, under a legal theory his lawyers advanced in a federal appeals court hearing Tuesday.

Trump is facing charges for attempting to overturn the 2020 election results. In his defense, his legal team contends that in trying to reverse Biden’s victory, Trump fell within the “outer perimeter” of his official duties and is thus shielded from prosecution.

Where does such reasoning lead? In the hearing, which Trump attended, one judge sketched ominous scenarios about what a president might do under that notion of broad presidential immunity.