Dylann Roof, pictured here after a run-in with the police in April, was arrested in North Carolina
A 21-year-old man suspected of killing nine people at a historic African-American church in Charleston, South Carolina, has been arrested.
Police said Dylann Roof, of Lexington, South Carolina, was detained during a traffic stop in Shelby, North Carolina.
The gunman is reported to have sat in on a bible study meeting for a full hour before opening fire on the group.
Six women and three men, including the church pastor, were killed. A hate crimes investigation has been launched.
US President Barack Obama said he and his wife had known several members of the Emanuel AME Church, including the pastor, Clementa Pinckney.
He called the church a "sacred place" in the history of Charleston and spoke of his confidence that the congregation and the community would "rise again".
He also raised the issue of gun ownership, saying "communities like this have had to endure tragedies like this too many times".
President Obama: ''This type of mass violence does not happen in other advanced countries''
"At some point," he said, "we as a country have to reckon with the fact that this type of massacre does not happen in other advanced countries".
At the scene: The BBC's Rajini Vaidyanathan
The streets close to the church are deserted, save for a few uniformed police officers. A trickle of people arrive to lay flowers for the victims.
"Peace for the church, the family and their loved ones," reads one handwritten note, tucked into a bouquet of bright flowers. A short drive away mourners have arrived for a vigil in memory of the deceased.
Rev Vanessa Johnson is from a nearby church but knew one of the reported victims, the Reverend Clementa Pinckney.
"All of us are in shock... We are at a loss for words," she says. The Emmanuel church holds a special place in this city's hearts, she adds, making the events of Wednesday night so difficult to digest.
The weekly bible study meeting was under way in the church on Calhoun Street when the shooting unfolded at about 21:00 local time (01:00 GMT Thursday).
Charleston police chief Gregory Mullen said that when police arrived at the scene eight people were already dead in the church and one other person died later in hospital. There were three survivors, he added.
Charleston Police Chief Greg Mullen: "I am so pleased we were able to resolve this case quickly"
Police released images from surveillance cameras showing a suspect they described as white and clean shaven with a slender build, entering the building an hour before the shooting.
He was later seen driving away in a black four-door saloon car.
Police and officials were quick to call it a hate crime, and the US Department of Justice said it would open a federal hate crimes investigation.
Speaking after the arrest, Attorney General Loretta Lynch said they would be "looking at all of the facts, all of the motivations" to determine the best way to prosecute any case.
Police issued images from a surveillance camera of the suspect and a vehicle
The killings have sent shockwaves through a community that has already experienced heightened racial tension in recent months.
The shooting two months ago of Walter Scott, an unarmed black man by a white police officer in North Charleston, prompted angry protests. The officer has since been charged with murder.
Clementa Pinckney, the 42-year-old pastor of the church, was also a Democratic state senator in South Carolina.
He had recently sponsored a bill to make body cameras mandatory for all police officers in South Carolina in response to the death of Walter Scott.