WASHINGTON — The Justice Department moved on Tuesday to allow certain federal inmates to remain on home confinement when the government declares an end to the Covid emergency, reversing a Trump-era legal opinion that said the Bureau of Prisons would have to recall them to federal facilities.The unusual shift was a rare instance when the department under Attorney General Merrick B. Garland reversed a high-profile Trump-era decision. It was also a victory for criminal justice advocates.“Thousands of people on home confinement have reconnected with their families, have found gainful employment and have followed the rules,” Mr. Garland said in a statement.Congress gave the Bureau of Prisons the authority to release federal inmates to home confinement as part of the Coronavirus Aid, Relief and Economic Security Act, passed in March 2020 to address threats posed by the coronavirus pandemic, including risks to people in overcrowded prisons.But five days before President Biden took office in January, the Justice Department’s Office of Legal Counsel determined that nearly all those people would need to return to prison once the government said the pandemic no longer constituted an emergency.Criminal justice advocates and some lawmakers — including Senator Richard J. Durbin, Democrat of Illinois Democrat and the chairman of the Judiciary Committee — pressed the new administration to reverse course. But in July, The New York Times reported that Biden administration lawyers had decided that the Trump-era memo had correctly interpreted the law.During a trip to Chicago days later, Mr. Durbin lobbied Mr. Garland to become personally involved, according to a person familiar with the matter. The next month, administration officials characterized the previous assessment as a preliminary review and said that a more formal one was underway.As an alternative to keep some inmates on home confinement from returning to prison, the White House worked on a clemency program for some nonviolent drug offenders and considered using compassionate release for others.Criminal justice advocates, deeming those plans inadequate, on Nov. 30 pushed White House officials including Susan E. Rice, the domestic policy adviser, to reconsider the Trump-era memo.Of the approximately 4,800 inmates placed on home confinement under the CARES Act, about 2,800 would return to prison if the coronavirus emergency were to end, according to Justice Department estimates.“We will exercise our authority so that those who have made rehabilitative progress and complied with the conditions of home confinement, and who in the interests of justice should be given an opportunity to continue transitioning back to society, are not unnecessarily returned to prison,” Mr. Garland said.A Justice Department spokeswoman confirmed that the attorney general had asked the Office of Legal Counsel to reconsider its memo.Christopher H. Schroeder, who took over the office in late October, signed the replacement memo, concluding that it was a “better” interpretation of the law.Mr. Garland called Mr. Durbin and inmate advocates on Tuesday to inform them of the reversal.Holly Harris, the president and executive director of Justice Action Network, a bipartisan criminal justice reform group, hailed the change. Mr. Garland said in a conversation with her that the new opinion was the legally correct conclusion; she called it a morally correct one.“People have gotten jobs and reconnected with their children,” Ms. Harris said. “The relief they have to be feeling right now is overwhelming.”The Trump-era memo had created a state of dread for people like Wendy Hechtman, who has more than eight years left in her sentence for producing a chemical analogue of fentanyl.“There’s so many families out there that were really just petrified,” said Ms. Hechtman, who called her young sons to tell them of the Justice Department’s announcement. “I’m just so relieved that I don’t have to hurt them unnecessarily again.”The new memo gives the Bureau of Prisons “discretion to permit prisoners in extended home confinement to remain there,” a decision that still leaves life for inmates in the hands of the Justice Department, said Udi Ofer, the director of the A.C.L.U.’s justice division.The Justice Department has declined to reverse some high-profile Trump-era legal decisions, continuing to keep secret a memo related to how William P. Barr, the former attorney general, interpreted the findings of the special counsel’s report on Russian election interference and to defend President Donald J. Trump in a defamation suit filed by the writer E. Jean Carroll.But the Justice Department under Mr. Garland has reversed course from the Trump administration on law enforcement and criminal justice issues. Mr. Garland imposed a moratorium on federal executions pending a review of the department’s policies and procedures. And he rescinded a policy that curbed the use of consent decrees to address police misconduct.