Dylann Storm was reportedly detained in Selby, North Carolina, some 13 hours after the shooting in Charleston.
Police said the white gunman sat in a bible study meeting for up to an hour before opening fire, killing six women and three men including the church pastor, Clementa Pinckney.
“I am very very pleased to announce that we have made an arrest in this case,” said Greg Mullen, Charleston police chief.
Police described the attack at the Emanuel African Methodist Episcopal Church as a “hate crime”.
A prayer meeting was going on at the time of the shooting at about 21:00 local time on Wednesday (02:00 Thursday Nigerian time) at the church in Calhoun Street.
Police had earlier released images from surveillance cameras showing him at the church, and also of a black four-door saloon car he was seen driving away in.
Speaking at a news briefing, city police chief Gregory Mullen said that six females and three males were killed, but that names would not be released until all families were notified.
“This is a very dangerous individual who should not be approached,” he said.
He said that when police arrived at the scene eight people were already dead in the church and that one other person died later in hospital. There were three survivors, he added.
A woman who survived the shooting told her family that the gunman said he was letting her live so she could report what happened, the Charleston Post and Courier reported.
She said the gunman had sat in the church before standing and opening fire, according to an official from the National Association for the Advancement of Colored People (NAACP).
The woman – who was not immediately identified – also told how the gunman spoke to her before he launched his killing spree.
According to the woman, the suspect reloaded five different times… and he just said “I have to do it. You rape our women and you’re taking over our country and you have to go.”
Charleston Mayor Joe Riley described the shooting as “the most unspeakable” tragedy.
South Carolina Senator Tim Scott tweeted: “My heart is breaking for Charleston and South Carolina tonight.”
“This is a very dangerous individual,” said Mullen.
Speaking from the White House on Thursday afternoon, President Barack Obama called the murders senseless.
“Any death of this sort is a tragedy, any shooting involving multiple victims is a tragedy,” he said.
“There is something particularly heartbreaking about death happening somewhere we seek solace and we seek peace.
“Methodist Emanuel is in fact more than a church, this is a place of worship that was founded by African Americans seeking liberty. This is a sacred place in the history of Charleston and in the history of America.”
He went on: “The fact that this took place in a black church also raises questions about a dark part of our history.”
He also spoke out about how the incident again signals the need for stricter gun control