Charleston County Sheriff Al Cannon Jr. said that Roof, who is white, was out of his cell and on his way to the shower when the attack happened at the Charleston County Detention Center.
Although he was in protective custody, Roof, 22, was vulnerable because only one guard was in the area and he was fetching toilet tissue for another inmate, Cannon said. That allowed another inmate, 25-year-old Dwayne Stafford, time to run down the stairs from his cell in the protective custody unit and assault Roof with his fists, the sheriff said.
No weapons were involved in the attack and Roof was able to return to his cell after being treated, Cannon said.
"The detention officer responded quickly and separated the two," Cannon said. "The injuries that Roof received are relatively minor -- some bruising around the face and the back. It appears he was struck with a fist and nothing more serious than that."
Roof, who is being kept in protective custody because the nature of his alleged crimes could make him vulnerable to assault, said he did not want to press charges, Cannon said.
The attack brought praise on Twitter with calls for donations to Stafford's jail commissary account.
Cannon gave no motivation for the beating. He said Stafford was able to attack Roof because guards had violated security procedures. Both guards weren't on the floor of the unit and Stafford's cell door was not checked to make sure it was secure before Roof was let out his cell, Cannon said.
Only one prisoner is allowed out of a cell at a time, Cannon said. Investigators are trying to determine how an electronic lock on Stafford's cell door failed to keep it locked, he said.
He said the attack is a "wake-up call" that officers must maintain vigilance in an environment where inmates can turn violent in an instant.
"We do things day in and day out and they become routine and as a result of that (officers) become complacent." Cannon said.
Roof faces the death penalty for the June 2015 shooting that killed nine people, including Rev. Clementa Pinckney, at the historic black church, known as "Mother Emanuel" African Methodist Episcopal Church. After he was captured, Roof told authorities he wanted to start a race war
with the killings.
On Monday his lawyers filed a legal challenge
to the U.S. death penalty, saying it was "arbitrary and cruel" and therefore unconstitutional. They said Roof would drop the challenge if federal prosecutors abandon their decision to seek the death penalty and allow him to plead guilty and receive a sentence of life without parole.
Roof is charged with 33 federal offenses, including hate-crime charges for allegedly targeting his victims on the basis of their race and religion.
"The nature of the alleged crime and the resulting harm compelled this decision," Attorney General Loretta Lynch said in May, regarding prosecutors' efforts to pursue the death penalty.