Former President Donald J. Trump declared in the first rally of his 2024 presidential campaign: “I am your retribution.” He later vowed to use the Justice Department to go after his political adversaries, starting with President Biden and his family.

Beneath these public threats is a series of plans by Mr. Trump and his allies that would upend core elements of American governance, democracy, foreign policy and the rule of law if he regained the White House.

Some of these themes trace back to the final period of Mr. Trump’s term in office. By that stage, his key advisers had learned how to more effectively wield power and Mr. Trump had fired officials who resisted some of his impulses and replaced them with loyalists. Then he lost the 2020 election and was cast out of power.

Since leaving office, Mr. Trump’s advisers and allies at a network of well-funded groups have advanced policies, created lists of potential personnel and started shaping new legal scaffolding — laying the groundwork for a second Trump presidency they hope will commence on Jan. 20, 2025.

In a vague statement, two top officials on Mr. Trump’s campaign have sought to distance his campaign team from some of the plans being developed by Mr. Trump’s outside allies, groups led by former senior Trump administration officials who remain in direct contact with him. The statement called news reports about the campaign’s personnel and policy intentions “purely speculative and theoretical.”

The plans described here generally derive from what Mr. Trump has trumpeted on the campaign trail, what has appeared on his campaign website and interviews with Trump advisers, including one who spoke with The New York Times at the request of the campaign.

If he wins another term, Mr. Trump has said he would use the Justice Department to have his adversaries investigated and charged with crimes, including saying in June that he would appoint “a real special prosecutor to go after” President Biden and his family. He later declared in an interview with Univision that he could, if someone challenged him politically, have that person indicted.

Allies of Mr. Trump have also been developing an intellectual blueprint to cast aside the post-Watergate norm of Justice Department investigatory independence from White House political direction.

Foreshadowing such a move, Mr. Trump had already violated norms in his 2016 campaign by promising to “lock up” his opponent, Hillary Clinton, over her use of a private email server. While president, he repeatedly told aides he wanted the Justice Department to indict his political enemies, including officials he had fired such as James B. Comey, the former F.B.I. director. The Justice Department opened various such investigations but did not bring charges — infuriating Mr. Trump and leading to a split in 2020 with his attorney general, William P. Barr.

Mr. Trump is planning an assault on immigration on a scale unseen in modern American history. Millions of undocumented immigrants would be barred from the country or uprooted from it years or even decades after settling here.

Bolstered by agents reassigned from other federal law enforcement agencies and state police and the National Guard, officials with Immigration and Customs Enforcement would carry out sweeping raids aimed at deporting millions of people each year. Military funds would be used to erect sprawling camps to hold undocumented detainees. A public-health emergency law would be invoked to shut down asylum requests by people arriving at the border. And the government would try to end birthright citizenship for babies born on U.S. soil to undocumented parents.

While in office, Mr. Trump mused about using the military to attack drug cartels in Mexico, an idea that would violate international law unless Mexico consented. That idea has since taken on broader Republican backing, and Mr. Trump intends to make the idea a reality if he returns to the Oval Office.

While the Posse Comitatus Act generally makes it illegal to use federal troops for domestic law enforcement purposes, another law called the Insurrection Act creates an exception. Mr. Trump wanted to invoke the Insurrection Act to use troops to crack down on protesters after the 2020 police killing of George Floyd, but was thwarted, and the idea remains salient among his advisers. Among other things, his top immigration adviser has said they would invoke the Insurrection Act at the southern border to use soldiers to intercept and detain undocumented migrants.

Mr. Trump and his backers want to increase presidential power over federal agencies, centralizing greater control over the entire machinery of government in the White House.

They have adopted a maximalist version of the so-called unitary executive theory, which says the president can directly command the entire federal bureaucracy and that it is unconstitutional for Congress to create pockets of independent decision-making authority.

As part of that plan, Mr. Trump also intends to revive an effort from the end of his presidency to alter civil-service rules that protect career government professionals, enabling him to fire tens of thousands of federal workers and replace them with loyalists. After Congress failed to enact legislation to block such a change, the Biden administration is developing a regulation to essentially Trump-proof the federal work force. However, since that is merely an executive action, the next Republican president could simply undo it the same way.

Politically appointed lawyers sometimes frustrated Mr. Trump’s desires by raising legal objections to his and his top advisers’ ideas. This dynamic has led to a quiet split on the right, as Trump loyalists have come to view the typical Federalist Society lawyer — essentially a mainstream Republican conservative — with disdain.

In a potential new term, Mr. Trump’s allies are planning to systematically install more aggressive and ideologically aligned legal gatekeepers who will be more likely to bless contentious actions. Mr. Trump and his 2024 campaign declined to answer a series of detailed questions about what limits, if any, he would recognize on his powers across a range of war, secrecy and law enforcement matters — many raised by his first term — in a New York Times 2024 presidential candidate survey.