Racism remains “a blight” on society, US President Barack Obama says, in the wake of the killing of nine African-Americans in a South Carolina church.
Police are treating the killings at the church in Charleston on Wednesday night as a hate crime.
Earlier, Dylann Roof, 21, appeared in court to face nine murder charges.
He showed no emotion as relatives of the victims addressed him directly. “I forgive you” said one victim’s daughter, fighting back tears.
Speaking in San Francisco, Mr Obama said: “The apparent motivations of the shooter remind us that racism remains a blight that we have to combat together.
“We have made great progress, but we have to be vigilant because it still lingers.
“And when it’s poisoning the minds of young people, it betrays our ideals and tears our democracy apart.”
But the president praised the families of the victims for the forgiveness they had shown.
He said it was “an expression of faith that is unimaginable but that reflects the goodness of the American people”.
Mr Obama also called for a new debate on gun control, and pushed Congress to follow public opinion.
“It’s not enough for us to express sympathy; we have to take action,” he said.
A previous proposed bill banning assault weapons failed to win backing in the Senate.
At a Charleston sports arena, thousands gathered on Friday evening to remember the victims with prayers. They joined hands to sing We Shall Overcome.
Ahead of the vigil, Mayor Joseph Riley said: “A hateful person came to this community with some crazy idea he’d be able to divide, but all he did was unite us and make us love each other even more.”
A steady stream of people also brought flowers to place at a memorial in front of the church.
The Roof family earlier released a statement through their lawyer.
“Words cannot express our shock, grief and disbelief as to what happened that night. We are devastated and saddened by what occurred,” the family wrote.
“We have all been touched by the moving words from the victims’ families offering God’s forgiveness and love in the face of such horrible suffering.”
In court in Charleston on Friday afternoon, Mr Roof spoke to confirm his name, age and address and said he was unemployed.
Then relatives were invited by the judge to come forward and speak.
A woman who identified herself as the daughter of Ethel Lance said: “You took something very precious from me. I will never talk to her ever again.
“I will never be able to hold her again, but I forgive you. And [may God] have mercy on your soul.”
The African-American church has a deep history of forgiveness rooted in faith and tied into the history of white supremacy in the US, writes journalist Adam Harris.
The ability to forgive has emerged as both an act of mercy and a tool against oppression.
Martin Luther King, himself a reverend, famously said: “We must develop and maintain the capacity to forgive. He who is devoid of the power to forgive is devoid of the power to love.
Anthony Thompson, a relative of Myra Thompson, told Mr Roof to repent and to turn to Jesus Christ. “I forgive you and my family forgives you,” he said.
Also speaking in court was Felecia Sanders, who survived the attack on Wednesday night by playing dead. Her son, Tywanza, was fatally wounded.
“We welcomed you Wednesday night in our Bible study with open arms.
“You have killed some of the most beautifulest people that I know. Every fibre in my body hurts … and I’ll never be the same,” she said to Mr Roof, who appeared via a video feed.
- Cynthia Hurd, 54
- Rev Clementa Pinckney, 41
- Rev Sharonda Coleman-Singleton, 45
- Tywanza Sanders, 26
- Ethel Lance, 70
- Rev Depayne Middleton-Doctor, 49
- Susie Jackson, 87
- Rev Daniel Simmons Sr, 74
- Myra Thompson, 59
Meanwhile, one of Mr Roof’s friends, Christon Scriven, told the BBC’s Rajini Vaidyanathan that Mr Roof had considered a university as a potential target.
Mr Scriven said Mr Roof “wanted to shoot that school up, UCA University of Charleston. It’s three miles up the street from that church”.
But Mr Scriven, who is black, did not think Mr Roof would actually follow through.
“So how do you take it serious?” he said. “How many friends do you have in your lifetime that’s killed somebody?”
Court documents have revealed new details about the shooting.
Mr Roof entered the church just after 20:00 local time (01:00 BST) on Wednesday night and remained with the worshippers for nearly an hour before launching his attack.
All of the victims were hit multiple times, the documents said.
Before leaving, Mr Roof stood over one person who was not shot and “uttered a racially inflammatory statement”.
That person has not been named, and has been described only as a “witness” in the court documents.
Mr Roof has been remanded in custody.
South Carolina Governor Nikki Haley said the state would “absolutely” look for the death penalty.
Cornell William Brooks, president of the National Association for the Advancement of Colored People, said: “This was not merely a mass shooting, not merely a matter of gun violence, this was a racial hate crime and must be confronted as such.”