The deal reached in the Charleston County Courthouse clears the way for his federal imprisonment, on death row, to begin.
"This is the surest way to see that Dylann Roof is executed," said Scarlett A. Wilson, solicitor for the state's Ninth Judicial Circuit. "We hope that today truly will close a chapter for these victims."
The deal means no state trial or sentencing phase will be necessary.
Roof pleaded guilty to nine murder charges, three attempted murder charges, and one weapons charge. He was sentenced to nine consecutive life sentences and three consecutive 30-year sentences.
Words of forgiveness, faith
He did not speak in court Monday, except to offer mostly one-word answers to questions from the judge.
Family members of victims spoke of forgiveness and resilience in the face of grief and hatred.
"The impact to the church has been far-reaching," the church's pastor, the Rev. Eric Manning, said in court. "We visit the crime scene every day. The impact has been felt throughout our entire congregation.
"Love is stronger than hate. Hate will never win."
Roof's grandfather, Joe Roof, said he and his family have been heartbroken.
"We are just sick over what has happened to these families," he said. "We have them in our prayers every night, every meal. It's the only thing we can do. What happened here, I will never understand."
Roof headed to federal death row
Roof is expected to be transferred to a facility in Terre Haute, Indiana, becoming the 63rd person on federal death row.
Roof told investigators in a recorded interview that he committed the crime because "black people are killing white people every day."
At the federal trial, Assistant US Attorney Jay Richardson said the admitted white supremacist scouted out his target multiple times, and sat with the church group in a Bible study class for 40 minutes before shooting. Richardson said Roof pulled the trigger "more than 75 times ... reloading seven times" as he stood over his victims, shooting them repeatedly.