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.
Who is shooting suspect Dylann Roof?
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".
"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".
The weekly bible study meeting was under way in the church on Calhoun Street when the shooting unfolded at about 9pm local time.
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.
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.
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.