CUMBERLAND, Md. — Last year, Al Moore was gulping down a dozen medications to cope with physical pain and sometimes crippling post-traumatic stress disorder that he developed during 30 years in the Marine Corps.

Those drugs have been replaced by what Moore describes as “the most holistic medicine you can have.”

“We call him ‘Kevin the wonder dog,’ ” Moore’s wife, Dawn, said Thursday, pointing to the Labrador retriever whose light brown eyes were fixed, as usual, on her husband. “He’s always wondering, ‘What can I do for you?’ ”

Kevin, a 3-year-old service dog with a golden fur coat, wakes Moore up when he has nightmares, keeps him steady when he gets dizzy on stairs and turns on lights when he enters rooms. He makes Moore feel comfortable in public spaces such as grocery stores and doctors’ offices, where he once couldn’t go without Dawn.

“It not just saved my life, but my family’s as well,” Moore told a room full of prisoners and staff at the maximum-security prison in this small town, moments before Kevin was reunited with the inmate who trained him.

Kevin is one of 23 service dogs trained at the Western Correctional Institution through a program run by America’s VetDogs, a nonprofit that pairs service dogs with veterans who are struggling with post-traumatic stress disorder. Sully, former president George H.W. Bush’s service dog who became a viral sensation at his funeral, was trained through the same program at a prison in Hagerstown, Md.

On Thursday, Moore, who has endured 19 surgeries over the past 27 years, directly addressed the inmates: “You guys are my heroes,” Moore said. “Heroes come from every walk of life.”

Sitting in the audience in the prison library, Herbert Wilson-Bey grinned. Kevin was the third service dog Wilson-Bey had trained, raising Kevin from the time he was a 6-week-old puppy until he was more than a year old and was mature enough to be paired with a veteran.

Wilson-Bey, 44, grew up in Baltimore and has spent his entire adult life in prison after being convicted of robbery and murder at age 17. Training the dogs, he said, has been one of his first real responsibilities. He has never held a job, and he could not help raise his son, who was 3 months old when Wilson-Bey went to prison.

The animals stay with inmates 24 hours a day Monday through Friday, then they spend weekends with volunteers so they are acclimated to life outside the prison.

“You are always working, but it is joyous work,” said Wilson-Bey, who joined the program in 2013 because he wanted to give back. “It’s like, if I put all my heart into this puppy, they are going to come out and be able to help someone.”

He initially thought bonding with the puppies was just about teaching them commands. Later, he understood the importance of showing them love.

“Put the puppy on your chest and let it feel your heart,” said Wilson-Bey, who wears a necklace with a dog-paw emblem around his neck. “Let it lick your face, even if you might not like that.”

Thursday’s appreciation ceremony was the first time Moore and another veteran met the inmates who trained their respective dogs, and the first time the inmates had seen their former trainees since they graduated.

It was meant as a celebration of the collaboration between America’s VetDogs and the Maryland Department of Public Safety and Correctional Services, which began in 2012 and which is part of the system’s effort to focus on restorative justice.

Of the six states with such prison training programs, Maryland boasts the biggest number of successfully trained dogs, said America’s VetDogs spokeswoman Sheila O’Brien.

“What could be more restorative than changing someone’s life for the better?” said Robert L. Green, who runs the state’s correctional department. “It’s all about healing.”

When Moore and his wife, who live in Fredericksburg, Va., drove up to the high-security prison, surrounded by rolling hills and changing leaves near the border of Maryland and West Virginia, they noticed that Kevin’s nose had shot into the air and that his tail was wagging.

Moore could tell the dog knew exactly where he was.

When Kevin saw Wilson-Bey, his whole body started shaking as he wagged even harder. Wilson-Bey crouched down as the dog nuzzled him.

“It was therapeutic for me, too,” Wilson-Bey told Moore, 59, as they talked after the ceremony about his training.

“Kevin pulled me out of an abyss that I didn’t know how to get out of,” Moore said. He started weaning himself off medications, which often made him feel forgetful and disconnected from his family, three months after being paired with Kevin in April. Six weeks ago, he stopped taking the last one.

America’s VetDogs is one of dozens of private organizations that train “psychiatric service” dogs that aim to help address the military’s mental health crisis. Proponents of such programs say that they help struggling veterans function better in society. But program officials have also faced questions about the effectiveness of their efforts, and who should pay for them.

It takes more than $50,000 to breed, raise, train, match and support a service dog trained through America’s VetDogs. After the puppies graduate from the prison training, they receive an additional three months of formal training, O’Brien said. The group then flies the veterans in and houses them for two weeks while they work with their new puppies. Veterans are never charged for the service; the organization relies largely on donations.

Catherine Abramshe, the other veteran who spoke at Thursday’s ceremony, said her post-traumatic stress disorder is still so bad that her life in the Pocono Mountains in Pennsylvania sometimes feels like “a beautiful prison.”

“Sorry guys,” she said to the inmates, after delivering that line in her speech.

Abramshe was working as a paramedic in New York City on Sept. 11, 2001; her partner, Ricardo Quinn, was among those killed in the attack. She deployed to Iraq as a medic in 2003, and said she began suffering symptoms of post-traumatic stress disorder in 2005.

She got divorced and lost her job. Before she was paired with Chesty, a 3-year-old black Lab, there were days when she stayed huddled under her covers.

“It is because of you that I get out of bed every day,” she told the inmates, some of whom were cradling and petting the next round of service dogs during the ceremony. “I will never forget how selfless you were giving up your time and your heart.”

When the inmates rose to give her a standing ovation, their dogs stayed calmly at their sides.