Around the country, it has become increasingly common for prosecutors’ offices to assign investigators to re-examine convictions when evidence suggests an error might have been made.

From San Francisco to Brooklyn, prosecutors now have teams of specialized investigators who sift through old evidence. Dozens of people have been freed every year because of findings of significant errors or evidence of police or prosecutorial misconduct. In Baltimore, Ms. Mosby’s office has cleared six other people of serious crimes since she took over.

The case of the three men released on Monday stood out for the length of time the men had served, and the ages at which they had been sent to prison: They spent more than twice as long behind bars as they had growing up at home. They had all along insisted that they were innocent, and they told people that every chance they got. Even when they had chances of parole, years into their sentences, they had been unable to get it because they were unwilling to admit to the killing.

Ms. Mosby’s office said that the case against the three men was plagued with misconduct, including lies told by Jonathan Shoup, the state’s attorney at the time , that unfairly tipped the case in prosecutors’ favor. Mr. Shoup died in 2016.

The three men, who were then 16-year-old high school students , had ditched classes on Nov. 18, 1983, and had been at the junior high visiting friends until a security guard kicked them off campus.

About 30 minutes later, DeWitt, the junior high student, was walking to lunch with friends when someone demanded his jacket. After a struggle, he was shot with a .22-caliber handgun in the neck and collapsed . He died two hours later.

The school shooting drew close attention at the time, and police officers had been under immense pressure to swiftly solve the case, prosecutors said.