Maryland’s corrections secretary, Gary D. Maynard, is resigning to take a senior position with a national criminal-justice organization, ending a seven-year tenure that was marred by a corruption scandal at a state-run jail in Baltimore.

Maynard was heavily recruited by Gov. Martin O’Malley (D) after O’Malley took office in 2007 and has been generally well regarded by lawmakers from both major political parties during his time in Maryland.

But he was criticized after more than a dozen guards at the Baltimore City Detention Center were indicted in April on charges of helping leaders of a dangerous national gang operate a drug-trafficking and money-laundering scheme from behind bars.

The announcement by the O’Malley administration Tuesday evening came a day before a legislative panel is scheduled to release recommendations in response to the scandal, which included the arrests last month of an additional 14 current or former state corrections officers.

In a statement, O’Malley praised Maynard’s tenure, saying: “Gary’s tireless work over the last seven years to make our correctional institutions safer and more secure has paved the way for stronger, safer communities across the State of Maryland.”

The statement recounted Maynard’s work to reduce recidivism rates and violence in state prisons and credited him with closing the antiquated House of Correction in Jessup early in his tenure.

Maynard is joining the Criminal Justice Institute, where he will serve as senior vice president. CJI is a private nonprofit organization that provides consultation and other services to jails and prison systems across the country.

In a statement, Maynard thanked O’Malley for having “faith in me and this department.”

Deputy Secretary Gregg Hershberger will become acting secretary of the Department of Public Safety and Correctional Services, O’Malley’s office said.

Del. John W.E. Cluster Jr. (R-Baltimore County), said he found the timing of the announcement “peculiar,” given that recommendations would be made by a legislative panel Wednesday in response to the Baltimore jail scandal.

“It shows that there are a lot of fixes that need to be made,” Cluster said. “It shows the deficiencies over the years. . . . He hasn’t managed his people tightly enough.”

House Speaker Michael E. Busch (D-Anne Arundel), however, said that he thought Maynard deserves “high marks” for managing the state’s prison system and that different challenges were presented at the Baltimore jail, which the state took over in 1991. In most jurisdictions, jails are managed by the local government.

In most jurisdictions, jails are managed by the local government.

“Secretary Maynard took personal responsibility for everything that took place there,” Busch said. “To a person, regardless of political affiliation, they will tell you he was hardworking and made a tremendous contribution to the corrections system.”

To many, Maynard and his deputies appeared flat-footed when the federal indictment was unsealed in the spring, and they were taken aback by criticism of the prison system included in court documents filed by federal investigators.

But Maynard seemed to recover quickly and maintained the governor’s support even after facing tough questions from state legislators in Annapolis. In a grand gesture, Maynard moved his office into the warden’s conference room at the detention center soon after the allegations were revealed.

He walked a fine line in his public comments, expressing revulsion at the alleged corruption while defending the prison system’s effort to expose it.

“Exposing ourselves to an internal investigation is risky and difficult, but it was the only way to get at the core problem,” Maynard said in an interview with The Washington Post soon after the indictment was unsealed.

The misconduct alleged in the second indictment occurred before the initial arrests in the spring, and prison officials could point to improvements made since then: changes in top leadership at the detention center, tougher screening procedures for inmates and employees, and the creation of an anti-corruption investigation team.