Donald J. Trump is set to become the first former president to be arraigned on federal charges when he appears in a Miami courtroom on Tuesday to face charges that he illegally retained national security documents after leaving office, obstructed efforts to retrieve them and made false statements about the matter.

His appearance at the Wilkie D. Ferguson Jr. federal courthouse comes a few days after an indictment that has upended historical precedent and shaken the political universe in the United States, making Mr. Trump both the first former commander in chief and the first presidential candidate to be charged with federal crimes.

During his court appearance, Mr. Trump is expected to be advised of his rights, and a judge will assess whether he has legal representation. The appearance could include an arraignment during which he would enter a plea; Mr. Trump is expected to plead not guilty.

Mr. Trump was expected to be arrested on Tuesday, but it was unclear whether U.S. marshals would take his fingerprints or photograph him. Those measures are normally used to help identify defendants, but when Mr. Trump was arraigned on unrelated state charges in New York in April, officials felt they were unnecessary given the former president’s level of fame.

Still, it was possible they could happen on Tuesday. Mr. Trump also could have to surrender his passport.

It was also unclear whether the public would get a glimpse of Mr. Trump as he arrived at the courthouse. The former president was expected to enter and exit through an underground garage. In the federal court system, there are no photographs or cameras allowed in the courtroom.

Officials were bracing for a potentially unruly scene in Miami after Mr. Trump called for crowds of his supporters to rally at his initial appearance, in a move reminiscent of the Jan. 6 attack on the Capitol by a pro-Trump mob.

A throng of news media organizations had gathered at the courthouse, setting up tents and crowding the perimeter, but few if any members of the public were in attendance.

Still, Mayor Francis X. Suarez of Miami, a Republican, called a news conference on Monday to instruct anyone who planned to protest that violence was not welcome in the city. Mr. Suarez said he believed in the right to protest but also in “law and order.”

Security at the courthouse was tight on Monday, with police and federal law enforcement officials sweeping the grounds.

“We encourage people to be peaceful,” Mr. Suarez said, adding, “We’re going to have the adequate forces necessary to ensure that.”

Mr. Suarez said the authorities might close roads near the courthouse depending on the size of any protests, and that commuters should expect possible disruption.

The case against Mr. Trump is the second criminal prosecution against the former president this year. Mr. Trump was already arraigned in April in a New York courthouse on state charges that he falsified business records.

In the case that has brought him to Miami, Mr. Trump has been charged with 37 counts of unauthorized retention of national security information. They relate to the former president’s hoarding of sensitive government documents after he left office and his refusal to return them, even after being subpoenaed for all remaining records in his possession that were marked as classified.

Two of Mr. Trump’s lawyers who had represented him in the classified documents investigation — James Trusty and John Rowley — resigned from his legal team last week.

Mr. Trump said he would be represented in the matter by a new lawyer, Todd Blanche. He will also be represented by Christopher M. Kise, a former solicitor general for the state of Florida who has won four cases before the United States Supreme Court.

The government is expected to be represented by Jay I. Bratt, a top official of the Justice Department’s national security division, and Julie Edelstein, the deputy chief of counterintelligence and export control.

After the court appearance, Mr. Trump is expected to fly to Trump National Golf Club in Bedminster, N.J., to give remarks defending himself in the evening.

Mr. Trump has called for his supporters to rally at the courthouse in his defense: “SEE YOU IN MIAMI ON TUESDAY!!!” he posted on Truth Social. Of particular concern for law enforcement is a planned rally at the courthouse, promoted on Telegram, by the far-right Proud Boys group. The Proud Boys, notably, were a major factor in the Jan. 6 attack. Members of the group were recently convicted of seditious conspiracy. Many of Mr. Trump’s most extreme supporters are reeling after more than 1,000 of them were arrested in connection with the storming of the Capitol on Jan. 6, 2021.

Mr. Trump’s arraignment in New York did not produce violence; crowds of rival protesters outside the courthouse were raucous but peaceful.

Manny Morales, the Miami police chief, said his force was prepared for a crowd of anywhere from 5,000 to 50,000 protesters. Chief Morales said officers would endeavor to keep any groups of rival protesters away from each other.

“We’re taking this event extremely serious,” he said. “We know that there’s a potential of things taking a turn for the worst. But that’s not the Miami way.”

Adam Goldman, Alan Feuer and Charlie Savage contributed reporting.