COLUMBIA, S.C. — An inmate awaiting trial on a murder charge planned an escape from a county jail in South Carolina by having fellow prisoners set fire to a mattress and attack guards trying to help them escape the smoke while he scaled a barbed wire-topped fence, authorities said.

But Stephen Stinnette was only free for about seven hours before deputies took him back into custody, Sumter County Sheriff Anthony Dennis said.

The sheriff said he poured as many deputies and other officers into the search as he could because Stinnette was so dangerous. Stinnette killed a man during an argument in 2018, buried his body and dug it up twice because he feared someone was talking to police before finally dumping the remains in Lake Marion, Dennis said.

Stephen Stinnette Sumter County Jail via AP

The escape plan started around 7 p.m. Thursday when an inmate set fire to a mattress. As staff at the Sumter County jail was taking the 60 inmates out of their cells and the unit filled with smoke, Stinnette and other prisoners attacked the guards, Dennis said.

"There is no doubt he is the mastermind," the sheriff said.

In the chaos, Stinnette and two other inmates made it to an outdoor recreation yard. Stinnette made it over the fence, while the other two inmates did not leave jail property, deputies said.

Stinnette spent seven hours trying to methodically make it to family members, avoiding police dogs and circling helicopters, but was caught about 1 mile (1.6 kilometers) from the jail as he moved from one place to another, Dennis said.

Stinnette got his mother and three other people to help him dig up and move 24-year-old Jerry Johnson's body after shooting him, according to court documents. They are all charged with accessory after the fact in the killing, but Dennis said at a news conference deputies don't think they had anything to do with the escape.

Stinnette gave up peacefully and told deputies about his plan, the sheriff said.

Stinnette had cuts and other injuries from scaling the fence and appeared to have been bitten by a snake. He was treated and temporarily taken back to the Sumter County Jail, Dennis said.

"He will be removed to another facility. He won't be housed here anymore," the sheriff said.

Two guards suffered minor injuries in the attack but should be OK, deputies said.

Dennis said he has called state officials to help with a full investigation of how safety can be improved at the jail and how the incident unfolded. Stinnette, the inmate who set the fire and other prisoners will likely face charges.

"The riot wasn't really long," Dennis said. "It was quickly contained. It was just enough distraction for Stinnette to escape."

Follow Jeffrey Collins on Twitter at https://twitter.com/JSCollinsAP.