Mayor Martin J. Walsh stood inside the South Bay House of Correction on Wednesday. His audience: two dozen inmates wearing brown prison jumpsuits. His message: Two things, he said, got him to City Hall — admitting he was powerless over alcohol, and the Serenity Prayer.

But as the inmates in the prison’s addiction recovery class stared blankly at the mayor, the tenor of his voice changed ever so slightly, offering a bit of tough love before returning to encouragement.

“I know some people are thinking in your heads right now: ‘He’s full of [expletive],’ and that’s OK. But I’m leaving when I get out of here,” said Walsh, who says he has been sober since April 1995. “I’m going back to City Hall to make Boston the best city in the world.”

Then Walsh again urged the prisoners to memorize and regularly recite step one of the 12 Steps of Recovery — proclaiming they’re powerless over addiction — and the Serenity Prayer, which begins “God, grant me the serenity to accept the things I cannot change.”

John Tlumacki/Globe Staff

Mayor Marty Walsh toured the South Bay House of Correction with Sheriff Steven W. Tompkins.

The mayor’s words came as part of an hourlong tour of the prison and several of its programs that aim to ease the process of reentering society for inmates upon release.

According to the Suffolk County Sheriff’s Department, more than 3,000 inmates are released annually from the House of Correction and 95 percent of them return to a community within five miles of the Dorchester lockup.

The mayor and Sheriff Steven W. Tompkins said focusing on what happens inside the prison is another element in combating the violence that takes place on the streets outside. As of last week, Boston had recorded 11 homicides this year, compared with five in the same period the year before, according to the Boston police.

‘We as a society can no longer afford to warehouse people. We have to correct actions when we can.’

STEVEN W. TOMPKINS, Suffolk sheriff

“On average, men and women are with us for 12 months, so they’re going home. How do you want them to return? The same, better, or worse?” Tompkins said by phone after the tour.

“We as a society can no longer afford to warehouse people. We have to correct actions when we can.”

Most of the more than 1,000 inmates at the House of Correction have little or no job training, come from unstable housing situations, are undereducated, and have committed drug- and alcohol-related offenses.

The prison offers programs to address these issues, everything from GED, computer literacy, and resume writing classes to vocational education in carpentry, painting, and landscaping.

And once a month, the social service providers, faith-based organizations, and law enforcement agencies that make up the Boston Reentry Initiative meet with offenders who pose the greatest risk of committing violent crimes once released.

John Tlumacki/Globe Staff

Walsh urged the prisoners to memorize and regularly recite step one of the 12 Steps of Recovery — proclaiming they’re powerless over addiction — and the Serenity Prayer, which begins “God, grant me the serenity to accept the things I cannot change.”

The initiative was founded 14 years ago in response to a spike in violence.

On Wednesday, seven men in prison jumpsuits, most in gangs and with gun charges on their records, sat across from men in suits and ties for the February meeting. One by one, the suit-and-tie set got up to address the inmates.

Walsh went first, telling these young men the by now well-known story about his road to sobriety and about a young man he mentored who was in and out of the criminal justice system so much he “knew jail better than the lawyers.”

That young man’s story does not end at City Hall as Walsh’s does, though. Walsh said the man relapsed and is incarcerated for breaking into a Dunkin’ Donuts.

Val Harris of the Dorchester Bay Economic Development Corp. shared a similar tale, saying, “the mayor’s story is not much different than mine except I have more clean time than him.”

So, he said, “Don’t sit there and tell me ‘I can’t change’ because I know you can.”

And if change does not happen, death or a long stretch in prison surely will, said Suffolk County Assistant District Attorney Daniel P. Mulhern, who heads the gang unit.

BostonGlobe.com complimentary digital access has been provided to you, without a subscription, for free starting today and ending in 14 days. After the free trial period, your free BostonGlobe.com digital access will stop immediately unless you sign up for BostonGlobe.com digital subscription. Current print and digital subscribers are not eligible for the free trial.

Thanks & Welcome to Globe.com

You now have unlimited access for the next two weeks.

BostonGlobe.com complimentary digital access has been provided to you, without a subscription, for free starting today and ending in 14 days. After the free trial period, your free BostonGlobe.com digital access will stop immediately unless you sign up for BostonGlobe.com digital subscription. Current print and digital subscribers are not eligible for the free trial.