A Missouri prison guard who used his job connections to hire a hit man to kill his wife's ex-husband got a surprise when the hired gun turned out to be an undercover FBI agent.

Corrections officer Robert W. Jones asked one of the inmates at the U.S. Medical Center for Federal Prisoners in Springfield, Mo., to help him find a hit man, according to the U.S. Attorney's Office.

Jones, 43, confided to the inmate that his wife had left him and blamed his wife's ex-husband for destroying his marriage, authorities said.

But unbeknownst to Jones, the inmate, a former leader in a drug trafficking organization, had agreed to cooperate with investigators by pretending to help Jones, authorities said.

The inmate discussed the matter with Jones 10 to 15 times in just two months in the spring of 2012, according to the FBI. Jones even offered to provide a cell phone so that the inmate's call to the hit man wouldn't be recorded on a prison land line, authorities said Wednesday as they unveiled the case.

For unrelated reasons, Jones was transferred to a different unit, authorities said, but when the inmate was transferred to Jones' new unit on June 12, 2012, they re-established contact.

Surveillance video showed Jones speaking to the inmate through an opening on his cell door multiple times in the month that followed, prosecutors said.

The inmate gave Jones a telephone number and suggested he contact a hit man named "Chuey," prosecutors said. Jones and the FBI agent posing as Chuey arranged to meet at the food court at the Battlefield Mall in Springfield, Mo. on July 13, prosecutors said.

At the food court, Jones offered to pay Chuey $1,500 for killing his wife's ex-husband, prosecutors said, noting he gave Chuey cash, a photo of the man and his home address. That's when Jones was arrested.

Jones originally pleaded of not guilty by reason of insanity, but on Wednesday he pleaded guilty to using a telephone with the intent of soliciting a murder for hire, the U.S. Attorney's office said.

Dee Wampler, Jones' attorney, told ABC News that his client is a veteran of the wars in Iraq and Afghanistan and suffers from depression and post-traumatic stress disorder.

"Mr. Jones is a distinguished war veteran," Wampler said. "He was given an honorable discharge and has no prior criminal record."

"But for his condition, he would have never committed the crime," Wampler added.

Jones is awaiting sentencing in federal custody and faces 10 years in prison without parole and a fine of up to $250,000. His attorney said he will ask the court for leniency at the sentencing based on Jones' mental illness.