A woman’s kidney donation has saved the life of an Alabama police officer who put her in jail.

Phil Campbell officer Terrell Potter had locked up Jocelynn James several times as she battled an opioid addiction.

She credits Potter, now retired, with helping her turn her life around. She has been sober for years.

Last November she found out Potter needed a kidney as she was looking at Facebook, Fox 11 Los Angeles reports.

His kidney had failed. Doctors told him he faced a seven- or eight-year wait for a new one.

NEW HAMPSHIRE WOMAN IS FIRST AMERICAN TO UNDERGO TWO FULL FACE TRANSPLANTS

Jocelynn James and retired Alabama police officer Terrell Potter. (Jocelynn James)

“I just threw my phone down and the Holy Spirit told me right then that I had that man’s kidney,” James said, according to the station.

ALABAMA GUNFIRE AT BASS PRO SHOPS STORE RESULTS IN 2 ARRESTS, OFFICER INJURED: REPORTS

Tests confirmed she was a perfect match.

“If you asked me 100 names of who may give me a kidney, her name would have not been on the list,” Potter said, according to the station. “It’s just unbelievable that she was willing to do that.”

James, who now runs a nonprofit that provides drug counseling to women, donated the kidney to Potter in July at Vanderbilt University Hospital in Nashville.

They are both doing well.

"In my mind, I'm just doing what God told me to do, give him my kidney," James told WVTM-TV, which first reported the story.

Potter told the station, “It’s very humbling to have somebody would give you a part of their body to extend your life.”

CLICK HERE TO GET THE FOX NEWS APP

Of the chances that James would be a match, he said, “It’s not a coincidence. It’s just God. There's no other way.”