Law enforcement officials and defense attorneys in Maryland, the District and throughout the country are taking steps to release inmates, drop pending prosecutions and lock up fewer new defendants to thin crowded prisons that public health officials say are ripe for spreading the coronavirus.

Nationally, a group of more than two dozen prosecutors in cities such as New York, San Francisco, Dallas and Baltimore called on police to cite and release suspects they arrest who pose no physical threat. Prosecutors also are asking jailers to release those who cannot afford cash bail and those who are elderly or within six months of finishing their sen­tences.

“We must act now to reduce the existing detained populations,” said Miriam Krinsky, executive director of Fair and Just Prosecution, which organized the prosecutors’ letter.

The top prosecutor and public defender in Prince George’s County, who are typically adversaries in the courtroom, asked a judge on Thursday to release from jail dozens of people who have been charged with low-level, nonviolent crimes and are awaiting trial.

Prince George’s District Judge Clayton A. Aarons ordered the release of 50 people after a day-long court session, and more cases are set for review Friday.

“A jail is essentially a petri dish. Once the virus gets in there, it could have a devastating effect,” said Public Defender Keith Lotridge, who is working with State’s Attorney Aisha Braveboy from a nearly empty courthouse in Upper Marlboro, Md.

“We are safely and responsibly recommending release” for pre­trial defendants, Braveboy said, because of concerns that the jail could become a “breeding ground and further prolong this crisis.”

In Ohio, hundreds of defendants awaiting trial have also been released since early March to reduce possible exposure, according to local news reports, and Kentucky public defenders and prosecutors are seeking release of more than 100 pretrial defendants accused of low-level crimes.

The effort to trim the prison population comes as officials at many facilities have reduced or stopped in-person visits for relatives and attorneys. Police departments are increasingly turning to warnings and citations instead of arrests and incarceration, and court officials are confirming ­cases of covid-19 among inmates and guards.

In D.C. Superior Court, Chief Judge Robert E. Morin signed a citywide order on Monday giving D.C. police as well as federal and local prosecutors discretion to decide whether to detain people who are arrested or to instead hand out a citation and order them to appear in court at a later date.

Two days later, officials reported that a U.S. marshal who works in one of the court’s busiest courtrooms had tested positive for the coronavirus. The marshal worked in Room C-10, where new defendants — as many as 20 to 100 a day — appear before a judge for the first time and in a second courtroom that handles initial hearings for juvenile defendants. On Thursday, 65 inmates being housed in the detention center have been quarantined in separate cells.

Defense attorneys have filed dozens of petitions to D.C. Superior Court judges to have their clients released from jail.

The U.S. attorney’s office in the District emphasized that it is making no changes in how it makes charging decisions, saying in a statement that it “remains steadfast in prosecuting violent offenders, a top priority for the Office.”

Baltimore’s top prosecutor, State’s Attorney Marilyn Mosby, announced this week that she had instructed prosecutors in her office to immediately drop charges and release people arrested for certain minor, nonviolent offenses — including drug possession and attempted distribution, prostitution and trespassing.

“As prosecutors, we are committed to protecting the safety and well-being of everyone in our community, and that includes people who are currently in prison or jail,” Mosby said in a statement. “I firmly believe that we can promote public health and public safety at the same time, and that’s what these new policies will achieve.”

In contrast, Maryland Gov. Larry Hogan — who has been asked by Mosby, the local American Civil Liberties Union and medical experts to release prisoners — cast doubt on the public health benefits of releasing inmates early.

“They’re safer where they are,” Hogan (R) said Thursday, likening correctional facilities to a quarantine space. “I don’t think it’d be a great idea.”

Similarly, in some parts of Virginia, defense attorneys say prosecutors have not changed their approach. In Richmond, the chief public defender, Tracy Paner, said, “The courts, prosecutors and police have done nothing to get people released from jail.” In one arraignment court, Paner said that 10 of 21 people were held without bond on misdemeanors and nonviolent felonies.

“Every prosecutor,” said Richmond Commonwealth’s Attorney Colette McEachin, “is balancing community safety with the need to minimize the number of persons who are incarcerated.”

Nina J. Ginsberg, president of the National Association of Criminal Defense Lawyers, said defense attorneys nationwide are filing motions to get their clients released.

“We have to get the largest number of people who do not pose a threat to public safety out of the local jails and prisons,” she said.

For people held in local jails pending trial, court orders are required to enable their release. Nearly all courts are staying open on a limited basis, in part to consider such requests.

But for people who have been given sentences to serve in their county jail, sheriffs have the authority to release inmates early or place them in home detention. Los Angeles County Sheriff Alex Villanueva said he has been releasing those who had less than 30 days to serve, among other steps to reduce the population of the nation’s largest jail.

Dane County, Wis., Sheriff David Mahoney, vice president of the National Sheriffs’ Association, said he and other sheriffs are freeing inmates as quickly as they can by using electronic monitoring and early release.

“Every sheriff, and there are more than 3,000 of us, is of the same mind-set,” Mahoney said. “We do not want the virus in our institutions. Because once it enters, it will spread like wildfire.”

Defense attorneys who have been able to meet with their clients say defendants report a “sense of fear, a sense of chaos and a sense of uncertainty” as they monitor the news by television and sporadic communication with friends and relatives, said Lotridge, the public defender in Prince George’s.

Civil rights groups also are calling on federal and state prison officials to release elderly inmates and those with chronic medical conditions that are considered a greater risk with covid-19. Of nearly a quarter-million federal inmates, more than 10,000 are older than 60, according to the letter from the American Civil Liberties Union addressed to the Federal Bureau of Prisons.

Scott Taylor, a bureau spokesman, said there are no known cases of covid-19 among inmates at the 122 federal prisons nationwide. He declined to comment on the ACLU letter and pointed to new bureau policies that include screening all new inmates for exposure to or symptoms of the novel coronavirus.

While governors in some states have ordered residents to avoid gatherings of more than 10 people, many jail units hold far more people, who are sleeping and eating in tight quarters, subjecting them to a higher risk of infection.

At the troubled Rikers Island jail in New York, where an inmate and an officer have tested positive, chief physician Ross MacDonald issued a stark warning to judges and prosecutors.

“We cannot socially distance dozens of elderly men living in a dorm, sharing a bathroom. Think of a cruise ship recklessly boarding more passengers each day,” he wrote on Twitter. “A storm is coming and I know what I’ll be doing when it claims my first patient. What will you be doing? What will you have done? We have told you who is at risk. Please let as many out as you possibly can.”

Keith L. Alexander, Erin Cox, Spencer Hsu and Hannah Natanson contributed to this report.