CHARLESTON, S.C. — The mass murder of nine people who gathered Wednesday night for Bible study at a historic black church has shaken a city whose history from slavery to the Civil War to the present is inseparable from the nation’s anguished struggle with race.
Fourteen hours after the massacre at Emanuel African Methodist Episcopal Church, in which the Rev. Clementa C. Pinckney, the church pastor and a prominent state senator was among the dead, the police on Thursday arrested Dylann Storm Roof, a 21-year-old white man with an unsettled personal life and a recent history of anti-black views.
The killings, with victims ranging in age from 26 to 87, left people stunned and grieving. Mr. Roof sat with church members for an hour and then started venting against African-Americans and opened fire on the group.
At Morris Brown African Methodist Episcopal Church here, blacks, whites, Christians and Jews gathered to proclaim that a racist gunman would not divide a community already tested by the fatal police shooting in April of an unarmed African-American, Walter Scott.
“We cannot make sense of what has happened, but we can come together,” declared the Rev. George Felder Jr., pastor of the New Hope A.M.E. Church.
Gov. Nikki R. Haley fought back tears, her voice trembling and cracking, at a news conference here. “We woke up today, and the heart and soul of South Carolina was broken,” she said. “Parents are having to explain to their kids how they can go to church and feel safe, and that is not something we ever thought we’d deal with.”
President Obama, once again having to confront the nation’s divisions, saw systemic issues of guns, violence and race in the tragedy in Charleston.
“We don’t have all the facts, but we do know that, once again, innocent people were killed in part because someone who wanted to inflict harm had no trouble getting their hands on a gun,” he said at the White House.
And quoting the Rev. Dr. Martin Luther King Jr. after four black girls were killed in the bombing of a black church in Birmingham, Ala., 52 years ago, he said the lessons of this tragedy must extend beyond one city and one church. He cited Dr. King’s words that their deaths were a demand to “substitute courage for caution,” and urging people to ask not just who did the killing but “about the system, the way of life, the philosophy which produced the murderers.”
Even amid calls here for calm and compassion, at least three bomb threats were made Thursday that forced the evacuation of buildings around Charleston, including churches where prayer vigils were being held for the shooting victims. And while the racially mixed crowds inside those churches linked arms and appealed for harmony, the tone among black people gathered on the city’s streets was not so conciliatory.
Jareem Brady, 42, said the shooting was only an extension of what black people face daily. “We’re not worth the air they don’t want us to breathe,” he said of Charleston’s white citizens.
The church holds a special place in the history of Charleston and particularly of its African-American population. It has the oldest black congregation south of Baltimore, according to the National Park Service, and its website calls it the oldest A.M.E. church in the South. The church’s current Gothic Revival building was completed in 1891, but the congregation dates to before 1820.
Of those killed, the most prominent was the church’s leader, Mr. Pinckney, 41.
“He was very gentle,” Mayor Joseph P. Riley said. “He spoke thoughtfully and deliberately. He had a big job, because that’s a big important church.”
Mr. Pinckney was holding a Bible study session with a small group Wednesday when, surveillance video shows, the suspect arrived after 8 p.m. — a slight, blond man with a bowl haircut and a gray sweatshirt. He sat down with the others for a while and listened, then began to disagree with others as they spoke about Scripture, said Kristen Washington, who heard the harrowing story from her family members who were in the meeting and survived.
Witnesses to the tragedy said the gunman actually asked for the pastor when he entered the church, and sat next to Mr. Pinckney during the Bible study.
They said that almost an hour after he arrived, the gunman suddenly stood and pulled a gun, and Ms. Washington’s cousin, Tywanza Sanders, 26, known as the peacemaker of the family, tried to calmly talk the man out of violence..
“You don’t have to do this,” he told the gunman, Ms. Washington recounted.
The gunman replied, “Yes. You are raping our women and taking over the country.”
In an interview with NBC News, Sylvia Johnson, a cousin of Mr. Pinckney’s who also spoke with a survivor, gave nearly the same account of what the gunman said: “I have to do it. You rape our women and you’re taking over our country. And you have to go.”
The gunman took aim at the oldest person present, Susie Jackson, 87, Mr. Sanders’ aunt, Ms. Washington said. Mr. Sanders told the man to point the gun at him, instead, she said, but the man said, “It doesn’t matter. I’m going to shoot all of you.”
Mr. Sanders dived in front of his aunt and the first shot struck him, Ms. Washington said, and then the gunman began shooting others. She said Mr. Sanders’ mother, Felicia, and his niece, lay motionless on the floor, playing dead, and were not shot.
The gunman looked at one woman and told her “that she was going to live so that she can tell the story of what happened,” said Councilman William Dudley Gregorie, a friend of both the female survivor and a trustee in the Emanuel church.
“She is still in shock, the carnage was just unbelievable is my understanding,” he said. “One of the younger kids in the church literally had to play dead, and it’s my understanding that my friend might have also laid down on top of him to protect him as well.”
The church had been unusually full that day, for its quarterly meeting, Mr. Gregorie said, and “if the perpetrator were to have come in earlier, there would have been many, many more people at the church.”
The gunman left six women and three men dead or dying, including a library manager, a former county administrator, a speech therapist who also worked for the church, and two ministers.
Greg Mullen, the Charleston police chief, called it a hate crime, and Attorney General Loretta Lynch said the Justice Department was investigating that possibility.
In a photo on his Facebook page, a glowering Mr. Roof (pronounced “Rawf”) wears symbols of two former white supremacist regimes — the flags of apartheid-era South Africa, and of Rhodesia, the nation that became Zimbabwe. Other photos, posted by a Facebook friend of his and widely circulated online, show Mr. Roof leaning against a car with a license plate that reads, “Confederate States of America.”
The tragedy had a particular resonance in a city that offers perhaps the sharpest contrast in the South between its cosmopolitan, tolerant present, and its antebellum past, when Charleston was the capital of the slave trade. It was in Charleston that a state convention adopted the “ordinance of secession” in December 1860, putting South Carolina on a path to become the first state to leave the Union, and the first shots of the Civil War were fired four months later, on Fort Sumter.
But if the church shooting prompted comparisons to the 1963 bombing of a black church in Birmingham by white supremacists that killed four girls, it also illustrated how much has changed. The earlier bombing took place as black people struggled to secure basic civil rights, at a time when they were barred from voting, much less holding office. Alabama’s governor at the time, George Wallace, was the public face of white resistance, and no one was charged with the crime until 12 years later.
The shooting Thursday took the life a black state legislator, an arrest was made in hours, and some of the most emotional expressions of mourning came from Ms. Haley, whose parents are from India, and who is not only the state’s first female governor, but also the first who is not of European descent.
Local, state and federal law enforcement started a manhunt for the suspect, distributing pictures of him entering the church, and asking people to be on the lookout for him or his 2000 Hyundai sedan. By midmorning Thursday, he had been identified as Mr. Roof, described as 5-foot-9 and weighing 120 pounds.
A short time later, someone reported possibly sighting him some 200 miles to the northwest, in Shelby, North Carolina. Jeffrey Ledford, the Shelby police chief, said officers there pulled Mr. Roof over, arrested him at 10:49 a.m., and found a gun in the car.
Mr. Roof waived extradition and was flown to South Carolina on Thursday evening and, amid extraordinary security, walked into the jail in Charleston County at 7:25 p.m.
As Mr. Roof, who was wearing a striped jail jumpsuit, entered the jail through a secured entrance, a police dog barked, cameras clicked and one woman muttered, “The bastard’s here.”
Nearby, a 15-year-old boy from North Charleston held a handwritten sign: “Your evil doing did not break our community! You made us stronger!”
The boy, Hikaym Rivers, said that he doubted Mr. Roof saw his message — and he questioned whether the accused killer would have cared if he noticed the sign — but he said it was important to make a public statement one night after the shooting in Charleston.
“We’re supporting our community, and we’re taking a stand that no one can just take this away from us,” he said. “It’s our peace of mind.”
Jail officials said that Mr. Roof would make a court appearance on Friday afternoon.
In Charleston, nicknamed “Holy City” for its large number of churches, many houses of worship held prayer vigils, for the dead and for survivors, that drew people from different communities, races and denominations together.
At the Morris Brown A.M.E. Church, just a few blocks from Emanuel, the mood of a packed house alternated between grief, hope and resilience. Calls of “enough is enough” echoed as the Rev. John Richard Bryant called for an end to gun violence.
“You look like a quilt, you look like patches,” Mr. Bryant said. “You all fit somewhere.”
Hundreds of people packed the pews of the white columned Second Presbyterian Church on Thursday evening in a vigil to remember the victims of the shooting. Pastors read Scriptures, the congregation sang and the Rev. Sidney Davis delivered a rousing sermon, his voice screeching at times. After reading a passage from the Bible, he said, “Last night, Satan came again. Satan came to say white and black cannot raise God.”
Later, he told the racially mixed congregation that the bullets were not simply penetrating the people who died in the church. “It was all of us dying last night,” he said.
An earlier version of this article misstated the location of Shelby, N.C. It is west, not east of Charlotte.