Speaker Nancy Pelosi told her House colleagues Friday that she had spoken to the Pentagon’s top general about keeping an “unstable president” from accessing the nuclear codes, as Democrats openly considered impeaching the commander in chief for the second time in just over a year.

The discussion with Army Gen. Mark A. Milley, the chairman of the Joint Chiefs, came after President Trump directed thousands of angry supporters to the Capitol on Wednesday as he refused to concede his election defeat. The crowds broke into the building in an insurrection now linked to the deaths of five people, including a Capitol police officer.

“The situation of this unhinged President could not be more dangerous, and we must do everything that we can to protect the American people from his unbalanced assault on our country and our democracy,” Pelosi (D-Calif.) wrote in a letter, in which she renewed the threat of impeaching Trump if Vice President Pence did not initiate proceedings for the Cabinet to remove the president under the 25th Amendment.

Army Col. Dave Butler, a spokesman for Milley, confirmed that a conversation with Pelosi did take place but offered little elaboration.

“Speaker Pelosi initiated a call with the Chairman,” he said in a statement. “He answered her questions regarding the process of nuclear command authority.”

The situation highlights the intense pressure that senior national security officials are under after an event unprecedented in American history.

The fact that Pelosi is talking to Milley about the topic is “alarming, and it shows just how dysfunctional things are right now,” said Jim Golby, an Army veteran and civil-military relations expert at the University of Texas at Austin.

Trump seemed to accept his fate in a video released Thursday, referring to the new administration, but tweeted on Friday that he will not attend President-elect Joe Biden’s inauguration on Jan. 20.

In her letter, Pelosi relayed that she and Senate Minority Leader Charles E. Schumer (D-N.Y.) had tried to reach Pence after Wednesday’s short-lived takeover of the U.S. Capitol by pro-Trump rioters but had not heard back.

“We still hope to hear from him as soon as possible with a positive answer as to whether he and the Cabinet will honor their oath to the Constitution and the American people,” Pelosi wrote.

“Nearly fifty years ago, after years of enabling their rogue President, Republicans in Congress finally told President [Richard M.] Nixon that it was time to go,” she said. “Today, following the President’s dangerous and seditious acts, Republicans in Congress need to follow that example and call on Trump to depart his office — immediately. If the President does not leave office imminently and willingly, the Congress will proceed with our action.”

The U.S. nuclear command-and-control structure gives the president sole authority to order the launch of nuclear weapons.

Some lawmakers, including Rep. Ted Lieu (D-Calif.) and Sen. Edward J. Markey (D-Mass.), have sought to roll back the president’s sole authority to launch such a strike, but their legislation has not received enough support in Congress.

Critics of that approach have said such restrictions could weaken deterrence and possibly encroach on the powers of the presidency.

As it stands, the president has latitude to order a nuclear strike, even if the United States has not been attacked first with a nuclear weapon.

If the president is considering a nuclear strike, top military and defense officials normally would convene in person and by phone to brief him on options and offer advice, including on whether the action conforms to laws of armed conflict. Then, if the president proceeds, the National Military Command Center would authenticate the president’s launch codes before any strike was carried out.

Milley, as Trump’s senior military adviser, is not in the chain of command and does not have the ability to stop a launch. But he could try to persuade others not to comply. He does have informal influence as the military’s senior officer, so he could try to persuade others not to launch.

“Legally, I can’t think of anything Milley could do beyond reminding everyone who is actually involved in the chain of command that it is illegal to execute an illegal order,” said James Acton, co-director of the nuclear policy program at the Carnegie Endowment for International Peace. “I can’t think of anything else he can do legally.”

But the military would handle different kinds of nuclear strike discussions differently, said Peter Feaver, an expert on civil-military relations and a political science professor at Duke University.

If another nation were to launch a nuclear strike against the United States, senior defense officials would be expected to bring the president legal courses of action that already have been vetted.

If the president were abruptly to call for a nuclear strike, however, the presumption of legality is not there, said Feaver, an adviser in the administration of President George W. Bush.

“The military is trained to say, ‘Can we just make sure this is legal, sir?’ ” Feaver said.

The grave nature of such decisions is the reason, he said, that while some senior Trump administration officials have resigned this week after the attack on the Capitol, senior national security officials are encouraged to stay.

Feaver said that former secretary of state Condoleezza Rice told the New York Times in an interview that officials’ remaining in their jobs sends a signal to adversaries that “the United States is prepared and functioning and they should not try to take advantage at this time.”

Feaver cited an example from the Nixon administration.

Former defense secretary James Schlesinger recounted that as secretary he directed military officials to consult him or Secretary of State Henry Kissinger before carrying out any possible nuclear strike that the president might order amid concerns about Nixon’s stability.

“In that situation, the presumption that the order is legal is relaxed,” Feaver said. “They’ll be asking questions, and that will create delays, and that will create opportunities for the rest of the team to make sure it’s the right decision.”

The president has the last say, however, according to assessments of the command-and-control authority. If civilian officials wanted to remove the possibility of Trump’s ordering a launch, they would need to rely on constitutional measures to do so, including the invocation of the 25th Amendment or impeachment.

Missy Ryan contributed to this report.