The nation's highest-ranking military officer said the armed forces will have "no role" in the 2020 presidential election or resolving any disputes, because courts and Congress have that responsibility.

Gen. Mark Milley, chairman of the Joint Chiefs of Staff, told two members of Congress in a letter that he "deeply" believes in the principle of an "apolitical" U.S. military and intends to keep the military out of any election dispute.

BIDEN SAYS TRUMP WILL ATTEMPT TO 'STEAL' PRESIDENTIAL ELECTION

“In the event of a dispute over some aspects of the election, by law U.S. courts and the U.S. Congress are required to resolve any disputes, not the U.S. Military,” Milley wrote. “I foresee no role for the U.S. Armed Forces in this process.”

Milley also said: "I will not follow an unlawful order."

Milley, the principal military adviser to the president, Secretary of Defense and National Security Council, was responding to questions raised by members of the House Armed Services Committee. They were concerned about President Trump's comments that he would deploy the military for domestic political purposes to quash protests. Lately, Trump has also suggested sending law enforcement to polling places, too.

JOINT CHIEFS CHAIRMAN MILLEY SAYS IT WAS 'MISTAKE' TO APPEAR WITH TRUMP IN LAFAYETTE SQUARE

Reps. Elissa Slotkin, D-Mich., and Mikie Sherrill, D-N.J., issued a joint statement welcoming the commitments Milley made in writing. They praised his pledges to "protect the military’s apolitical status, avoid military involvement in the election process, respect the peaceful transition of presidential authority under the Constitution and refuse to obey any unlawful orders."

FILE - In this June 1, 2020 file photo, President Donald Trump departs the White House to visit outside St. John's Church, in Washington. Part of the church was set on fire during protests on Sunday night. Walking behind Trump from left are, Attorney General William Barr, Secretary of Defense Mark Esper and Gen. Mark Milley, chairman of the Joint Chiefs of Staff. Milley says his presence created a perception of the military involved in domestic politics. He called it "a mistake" that he has learned from. (AP Photo/Patrick Semansky)

FILE - In this June 1, 2020 file photo, President Donald Trump departs the White House to visit outside St. John's Church, in Washington. Part of the church was set on fire during protests on Sunday night. Walking behind Trump from left are, Attorney General William Barr, Secretary of Defense Mark Esper and Gen. Mark Milley, chairman of the Joint Chiefs of Staff. Milley says his presence created a perception of the military involved in domestic politics. He called it "a mistake" that he has learned from. (AP Photo/Patrick Semansky)

Milley and Defense Secretary Mark Esper both expressed regret for accompanying Trump on a photo op in front of St. John's Church near the White House, where he held up a Bible. Law enforcement forcibly cleared Lafayette Square of racial justice protesters ahead of the D.C. curfew in advance of Trump's short walk to the church.

Milley, who was in uniform for the June 1 photo, called his presence "a mistake" because it gave the impression the military supports Trump's domestic political agenda.

“That sparked a national debate about the role of the military in civil society,” Milley said in a video in June. “I should not have been there."

Democrats have raised concerns that if Trump loses in November he might refuse to leave the White House. They've pointed to Trump's repeated statements aimed at discrediting the validity of the election by making unsubstantiated claims that universal mail-in voting is rife with fraud and by suggesting that the election should be delayed altogether over election security.

PELOSI RIPS TRUMP FOR TRYING TO 'SCARE' VOTERS: 'DON'T PAY ANY ATTENTION TO WHAT THE PRESIDENT IS SAYING'

"It’s my greatest concern, my single greatest concern," Democratic nominee Joe Biden said in an interview in June with "The Daily Show."  "This president is going to try to steal this election. This is a guy who said that all mail-in ballots are fraudulent ... while he sits behind the desk in the Oval Office and writes his mail-in ballot to vote in a primary."

Biden suggested the military might have to get involved to remove Trump from the White House.

“I promise you,” he said, “I am absolutely convinced [the military] will escort him from the White House with great dispatch.”

Milley, however, sought to make clear that the military will stay out of elections and the transfer of power. He said he does not want the military at polling places or involved in determining the outcome, either.

“We follow the rule of law and have done so with regard to past elections and will continue to do so in the future," he wrote. "I do not see the U.S. military as part of this process; this is the responsibility of Congress, the Supreme Court, and components of the executive branch.”