He arrived at the Calhoun Street church at 8:17 p.m., a pale, gaunt young man with a fishbowl haircut and putty-like features. He passed under the great steeple of Emanuel AME and opened the tall wooden door. He wore a gray sweatshirt and a dark pouch around his waist.
He was not entering just any church, but a preeminent symbol of the South's black faith community and a sanctuary for generations of worshipers. Parishioners had gathered for their Wednesday evening prayer meeting, and they welcomed him.
For nearly an hour, he sat among them, police say. He chose a spot near the pastor leading the service, Clementa C. Pinckney, a 41-year-old father of two and a state senator.
Then, police say, 21-year-old Dylann Storm Roof pulled out his gun and began firing, shouting, "I have to do this." Police say he shot Pinckney first, methodically firing and reloading until the pastor and eight others were mortally wounded.
Police said he left three survivors, one of whom told police he allowed her to live so she could tell her story.
Amid a massive manhunt, Roof fled more than 200 miles to Shelby, N.C., where police say they caught him Thursday morning during a traffic stop.
The shooting has resonated across the country, in a year when race relations have surged to the forefront after a series of violent episodes involving police and black citizens. Among the most vivid was a white officer's fatal shooting of an unarmed black man, Walter Scott, in April in North Charleston, about 10 miles away from Wednesday's violence.
U.S. Atty. Gen. Loretta Lynch said the church shooting would be investigated as a hate crime.
President Obama said he was saddened and angry. "There is something particularly heartbreaking about the death happening in a place in which we seek solace and we seek peace, in a place of worship," he said.
Obama called on the nation to act against gun violence. "At some point we as a country will have to reckon with the fact that this type of mass violence does not happen in other developed countries," he said.
The day after the shooting, hundreds of Charleston residents, black and white, came together for a prayer vigil at Morris Brown AME Church, a nearby sister church to Emanuel African Methodist Episcopal.
Mourners crowded into every pew and balcony seat. Hundreds listened outside in the hot sun. Ordinary citizens, local and state officials, congressmen and ministers from across the city attended.
Religious leaders exhorted the audience not to turn to racial animosity. "God take out of our hearts our fear and help us walk in boldness," one of the ministers prayed. "God take out the animosity and the hatred from our hearts."
U.S. Rep. James E. Clyburn (D-S.C.) called on the congregation to speak out against racism and injustice. "I'm here today to beg you, when you leave these hallowed halls, please break your silence," he said. "Speak up. If we stay silent, they win. They must not win."
Charleston is a city small enough that the killings feel personal, city Councilman Keith Waring said after the 90-minute service. "We are all interconnected. That's why it hurts."
Marvin Stewart said he was grieving for Cynthia Hurd, 54, his co-worker at the public library.
"I just saw her yesterday," he said. "I have known her for 25 years. She helped decorate my house." The libraries were closed Thursday in mourning, he said.
"This is just pure evil at work. It is beyond race," Stewart said.
Many agreed with Stewart that racial hatred was not a sufficient explanation for what had happened.
"How do you explain hate? Hate doesn't have a color," said the Rev. John Richard Bryant. The shooter picked the wrong city and the wrong community to attack, he said, because Charleston would not react with hatred.
But Dot Scott, president of the Charleston NAACP, said afterward that "the shooter made clear it was about race. This is the state of South Carolina."
She added that the string of killings of African American men by police around the country had become the "fertilizer for this mind-set" that led to the church massacre.
Charleston Mayor Joseph Riley pledged to reach out to Emanuel AME Church, a majority black congregation with a long and distinguished history that traces its roots to the antebellum period.
"We will put our arms around that church and that church family," Riley said. The shooting, he said, was the deed of "a horrible, hateful person," and was "beyond any comprehension."
Richard Cohen, president of the Southern Poverty Law Center in Alabama, which tracks racial hate crimes, said the attack, said to be by a white man on an important and long-standing black church, was "an obvious hate crime by someone who feels threatened by our country's changing demographics and the increasing prominence of African Americans in public life."
Cohen said the Charleston shooting was all the more troubling because, according to the police account, the assailant brazenly walked into the church, stayed an hour and acted like one of the congregation in prayer.
"It's incredibly creepy," Cohen said. "He walks into a black church and then stands up and opens fire. Maybe he waited first to get his courage up, or he was having second thoughts."
But Cohen said it was "classic white supremacy" behavior to pretend to be part of a group you want to target.
He said there are 16 white supremacy and hate organizations in South Carolina. He noted that many young people scour the Internet and are radicalized in that way, much like terrorists.
Roof's Facebook page shows him wearing a dark jacket bearing emblems associated with the white supremacist movement — the flags of apartheid-era South Africa and white-ruled Rhodesia, now known as Zimbabwe.
"Since 9/11, our country has been fixated on the threat of jihadi terrorism. But the horrific tragedy at the Emanuel AME reminds us that the threat of home-grown domestic terrorism is very real," Cohen said.
Gov. Nikki Haley said the shooter's hate would not divide South Carolina.
"He was hoping to divide this state and this country," she added. "But what he doesn't know is what he did is going to bring us a whole lot closer."
Pinckney, the slain pastor and state senator, had sponsored a bill to equip police agencies in the state with body cameras. The legislative push came after Walter Scott's killing by an officer who faces murder charges after a bystander captured the incident on video.
Roof had been arrested twice in Columbia, S.C., this year for drug possession and trespassing at a mall, police reports show.
Mass shootings appear to be on the rise across the country, according to researchers at Harvard University and Northeastern University, who found that such an incident — with four or more victims — occurred on average every 64 days in the two years leading up to September 2013.
In the 29 years before that, they found, such shootings occurred every 200 days on average.
At Emanuel AME, dozens of floral bouquets and balloons signified Charleston's sympathy.
Joyce Gilliard prayed in a tearful, close embrace with Rhonda Johnson and her two daughters from Wilmington, N.C.
Gilliard said a close friend of her family lost two aunts and a cousin in the church carnage.
"My heart is hurting," Gilliard said. "I wanted to be here for the community."
The Rev. Al Sharpton, a sometimes polarizing civil rights leader from New York, was muted in his comments after praying in front of Emanuel AME.
It is "a time for healing," not political commentary, Sharpton said. Noting that the victims were at Bible study, he said, "If we can't go to church, where can we go?"
Phelps reported from Charleston, Goffard from Los Angeles and Serrano from Washington. Times staff writers Christine Mai-Duc, James Queally, Hailey Branson-Potts, Katie Shepherd and Brittny Mejia in Los Angeles contributed to this report.