Nine days before Barack Obama delivered a eulogy at Charleston’s Emanuel African Methodist Episcopal Church, Dylann Roof entered the historic black institution, sat for a while, and then opened fire with a Glock handgun. The white supremacist, who liked to pose for photographs on the sites of former slave plantations, murdered nine people.

The attack stunned the nation. The fact that Roof was just 21 was the starkest of proof that the toxic racism of previous generations was alive and well.

The President’s job on 26 June 2015 was to offer solace not just to the people of Charleston, but to the nation. He spoke of the role of the church within African-American history as a place of strength and defiance. He said it was also a place of grace.

Watch Obama sing 'Amazing Grace':

Many relatives of those who had been killed had already displayed such strength, offering forgiveness to Roof and including him in their prayers, even as they were mourning their loved ones.

Mr Obama had apparently been unsure whether to sing the words to the hymn "Amazing Grace". As it was, his delivery – inexpert, apparently unrehearsed – was nothing less than startling.

Full transcript below:

Giving all praise and honour to God.

The Bible calls us to hope. To persevere, and have faith in things not seen.

“They were still living by faith when they died,” scripture tells us. “They did not receive the things promised; they only saw them and welcomed them from a distance, admitting that they were foreigners and strangers on Earth.”

We are here today to remember a man of God who lived by faith. A man who believed in things not seen. A man who believed there were better days ahead, off in the distance. A man of service who persevered, knowing full well he would not receive all those things he was promised, because he believed his efforts would deliver a better life for those who followed.

To Jennifer, his beloved wife; to Eliana and Malana, his beautiful, wonderful daughters; to the Mother Emanuel family and the people of Charleston, the people of South Carolina.

I cannot claim to have the good fortune to know Reverend Pinckney well. But I did have the pleasure of knowing him and meeting him here in South Carolina, back when we were both a little bit younger. (Laughter.) Back when I didn’t have visible grey hair. The first thing I noticed was his graciousness, his smile, his reassuring baritone, his deceptive sense of humour – all qualities that helped him wear so effortlessly a heavy burden of expectation.

Friends of his remarked this week that when Clementa Pinckney entered a room, it was like the future arrived; that even from a young age, folks knew he was special. Anointed. He was the progeny of a long line of the faithful – a family of preachers who spread God’s word, a family of protesters who sowed change to expand voting rights and desegregate the South. Clem heard their instruction, and he did not forsake their teaching.

He was in the pulpit by 13, pastor by 18, public servant by 23. He did not exhibit any of the cockiness of youth, nor youth’s insecurities; instead, he set an example worthy of his position, wise beyond his years, in his speech, in his conduct, in his love, faith, and purity.

Barack Obama's best moments in the White House Show all 11 1 /11 Barack Obama's best moments in the White House Barack Obama's best moments in the White House May 19, 2009 “The President was leaving the State Floor after an event and found Sasha in the elevator ready to head upstairs to the private residence. He decided to ride upstairs with her before returning to the Oval Office,” Peter Souza Barack Obama's best moments in the White House Oct. 26, 2012 President Barack Obama pretends to be caught in Spider-Man's web as he greets the son of a White House staffer in the Outer Oval Office Peter Souza Barack Obama's best moments in the White House “A National Security staffer, Carlton Philadelphia, brought his family to the Oval Office for a farewell photo with President Obama. Carlton’s son, Jacob, softly told the President he had just gotten a haircut like President Obama, and asked if he could feel the President’s head to see if it felt the same as his.” Peter Souza Barack Obama's best moments in the White House March 21, 2010 The President, Vice President and senior staff applaud after watching on television the House vote on H.R. 4872 for health care reform, in the Roosevelt Room of the White House Peter Souza Barack Obama's best moments in the White House Dec. 3, 2009 President Barack Obama fist-bumps custodian Lawrence Lipscomb in the Eisenhower Executive Office Building following the opening session of the White House Forum on Jobs and Economic Growth Peter Souza Barack Obama's best moments in the White House Sept. 22, 2015 "The Obama family and Biden family greet Pope Francis as he arrives in the United States for the first time at Joint Base Andrews," Sept. 22, 2015. Peter Souza Barack Obama's best moments in the White House Feb. 21, 2014 President Barack Obama and Vice President Joe Biden participate in a "Let's Move!" video taping on the Colonnade of the White House, Feb. 21, 2014 Peter Souza Barack Obama's best moments in the White House Feb. 18, 2016 President Barack Obama watches First Lady Michelle Obama dance with 106-Year-Old Virginia McLaurin in the Blue Room of the White House prior to a reception celebrating African American History Month, Feb. 18, 2016 Peter Souza Barack Obama's best moments in the White House Jan. 21, 2013 "The President and First Lady wave to supporters as they ride in the inaugural parade. I had asked the President if I could ride in the presidential limousine and the President joked, 'But Michelle and I were planning to make out," Jan. 21, 2013. Peter Souza Barack Obama's best moments in the White House Barack Obama and former First Lady Michelle Obama share a private moment in a freight elevator at an Inaugural Ball, January 2009 all pics: Pete Souza Barack Obama's best moments in the White House Barack Obama rests his hand on the bible that President Lincoln used for his swear-in, being held by his wife Michelle Obama as he is sworn in as the 44th President of the United States of America Rex

As a Senator, he represented a sprawling swath of the Lowcountry, a place that has long been one of the most neglected in America. A place still wracked by poverty and inadequate schools; a place where children can still go hungry and the sick can go without treatment. A place that needed somebody like Clem.

His position in the minority party meant the odds of winning more resources for his constituents were often long. His calls for greater equity were too often unheeded, the votes he cast were sometimes lonely. But he never gave up. He stayed true to his convictions. He would not grow discouraged. After a full day at the capitol, he’d climb into his car and head to the church to draw sustenance from his family, from his ministry, from the community that loved and needed him. There he would fortify his faith, and imagine what might be.

Reverend Pinckney embodied a politics that was neither mean, nor small. He conducted himself quietly, and kindly, and diligently. He encouraged progress not by pushing his ideas alone, but by seeking out your ideas, partnering with you to make things happen. He was full of empathy and fellow feeling, able to walk in somebody else’s shoes and see through their eyes. No wonder one of his senate colleagues remembered Senator Pinckney as “the most gentle of the 46 of us – the best of the 46 of us.”

Clem was often asked why he chose to be a pastor and a public servant. But the person who asked probably didn’t know the history of the AME church. As our brothers and sisters in the AME church know, we don't make those distinctions. “Our calling,” Clem once said, “is not just within the walls of the congregation, but the life and community in which our congregation resides.”

He embodied the idea that our Christian faith demands deeds and not just words; that the “sweet hour of prayer” actually lasts the whole week long – that to put our faith in action is more than individual salvation, it's about our collective salvation; that to feed the hungry and clothe the naked and house the homeless is not just a call for isolated charity but the imperative of a just society.

What a good man. Sometimes I think that's the best thing to hope for when you're eulogised – after all the words and recitations and resumes are read, to just say someone was a good man.

You don’t have to be of high station to be a good man. Preacher by 13. Pastor by 18. Public servant by 23. What a life Clementa Pinckney lived. What an example he set. What a model for his faith. And then to lose him at 41 – slain in his sanctuary with eight wonderful members of his flock, each at different stages in life but bound together by a common commitment to God.

Cynthia Hurd. Susie Jackson. Ethel Lance. DePayne Middleton-Doctor. Tywanza Sanders. Daniel L. Simmons. Sharonda Coleman-Singleton. Myra Thompson. Good people. Decent people. God-fearing people. (Applause.) People so full of life and so full of kindness. People who ran the race, who persevered. People of great faith.

Violence on the streets of Charlottesville Show all 9 1 /9 Violence on the streets of Charlottesville Violence on the streets of Charlottesville Protesters clash and several are injured White nationalist demonstrators clash with counter demonstrators at the entrance to Lee Park in Charlottesville, Virginia. A state of emergency is declared, August 12 2017 Violence on the streets of Charlottesville Trump supporters at the protest A white nationalist demonstrator walks into Lee Park in Charlottesville, Va., Saturday, Aug. 12, 2017. Hundreds of people chanted, threw punches, hurled water bottles and unleashed chemical sprays on each other Saturday after violence erupted at a white nationalist rally in Virginia. AP Photo Violence on the streets of Charlottesville State police stand ready in riot gear Virginia State Police cordon off an area around the site where a car ran into a group of protesters after a white nationalist rally in Charlottesville, Virginia AP Photo Violence on the streets of Charlottesville Militia armed with assault rifles White nationalists, neo-Nazis and members of the 'alt-right' with body armor and combat weapons evacuate comrades who were pepper sprayed after the 'Unite the Right' rally was declared a unlawful gathering by Virginia State Police. Militia members marched through the city earlier in the day, armed with assault rifles. Getty Images Violence on the streets of Charlottesville Statue of Confederate General Robert E Lee The statue of Confederate General Robert E. Lee stands behind a crowd of hundreds of white nationalists, neo-Nazis and members of the 'alt-right' during the 'Unite the Right' rally 12 August 2017 in Charlottesville, Virginia. They are protesting the removal of the statue from Emancipation Park in the city. Getty Images Violence on the streets of Charlottesville Racial tensions sparked the violence White nationalists, neo-Nazis and members of the 'alt-right' exchange insults with counter-protesters as they attempt to guard the entrance to Lee Park during the 'Unite the Right' rally Getty Violence on the streets of Charlottesville A car plows through protesters A vehicle drives into a group of protesters demonstrating against a white nationalist rally in Charlottesville, Virginia. The incident resulted in multiple injuries, some life-threatening, and one death. AP Photo Violence on the streets of Charlottesville Rescue personnel help injured people after a car ran into a large group of protesters after an white nationalist rally in Charlottesville, Virginia AP Photo Violence on the streets of Charlottesville President Donald Trump speaks about the ongoing situation in Charlottesville, Virginia from his golf club in Bedminster, New Jersey. He spoke about "loyalty" and "healing wounds" left by decades of racism.

To the families of the fallen, the nation shares in your grief. Our pain cuts that much deeper because it happened in a church. The church is and always has been the centre of African-American life – a place to call our own in a too-often hostile world, a sanctuary from so many hardships.

Over the course of centuries, black churches served as “hush harbours” where slaves could worship in safety; praise houses where their free descendants could gather and shout hallelujah – rest stops for the weary along the Underground Railroad; bunkers for the foot soldiers of the Civil Rights Movement. They have been, and continue to be, community centres where we organise for jobs and justice; places of scholarship and network; places where children are loved and fed and kept out of harm’s way, and told that they are beautiful and smart – and taught that they matter. That’s what happens in church.

That’s what the black church means. Our beating heart. The place where our dignity as a people is inviolate. And there’s no better example of this tradition than Mother Emanuel – a church built by blacks seeking liberty, burned to the ground because its founder sought to end slavery, only to rise up again, a phoenix from these ashes.

When there were laws banning all-black church gatherings, services happened here anyway, in defiance of unjust laws. When there was a righteous movement to dismantle Jim Crow, Dr. Martin Luther King, Jr. preached from its pulpit, and marches began from its steps. A sacred place, this church. Not just for blacks, not just for Christians, but for every American who cares about the steady expansion of human rights and human dignity in this country; a foundation stone for liberty and justice for all. That’s what the church meant.

We do not know whether the killer of Reverend Pinckney and eight others knew all of this history. But he surely sensed the meaning of his violent act. It was an act that drew on a long history of bombs and arson and shots fired at churches, not random, but as a means of control, a way to terrorise and oppress. An act that he imagined would incite fear and recrimination; violence and suspicion. An act that he presumed would deepen divisions that trace back to our nation’s original sin.

Oh, but God works in mysterious ways. God has different ideas.

He didn’t know he was being used by God. Blinded by hatred, the alleged killer could not see the grace surrounding Reverend Pinckney and that Bible study group – the light of love that shone as they opened the church doors and invited a stranger to join in their prayer circle. The alleged killer could have never anticipated the way the families of the fallen would respond when they saw him in court – in the midst of unspeakable grief, with words of forgiveness. He couldn’t imagine that.

The alleged killer could not imagine how the city of Charleston, under the good and wise leadership of Mayor Riley – how the state of South Carolina, how the United States of America would respond – not merely with revulsion at his evil act, but with big-hearted generosity and, more importantly, with a thoughtful introspection and self-examination that we so rarely see in public life.

Blinded by hatred, he failed to comprehend what Reverend Pinckney so well understood – the power of God’s grace.

This whole week, I’ve been reflecting on this idea of grace. The grace of the families who lost loved ones. The grace that Reverend Pinckney would preach about in his sermons. The grace described in one of my favourite hymnals – the one we all know: amazing grace, how sweet the sound that saved a wretch like me. I once was lost, but now I’m found; was blind but now I see. (Applause.)

According to the Christian tradition, grace is not earned. Grace is not merited. It’s not something we deserve. Rather, grace is the free and benevolent favour of God – as manifested in the salvation of sinners and the bestowal of blessings. Grace.

As a nation, out of this terrible tragedy, God has visited grace upon us, for he has allowed us to see where we’ve been blind. He has given us the chance, where we’ve been lost, to find our best selves. We may not have earned it, this grace, with our rancour and complacency, and short-sightedness and fear of each other – but we got it all the same. He gave it to us anyway. He’s once more given us grace. But it is up to us now to make the most of it, to receive it with gratitude, and to prove ourselves worthy of this gift.

For too long, we were blind to the pain that the Confederate flag stirred in too many of our citizens. It’s true, a flag did not cause these murders. But as people from all walks of life, Republicans and Democrats, now acknowledge – including Governor Haley, whose recent eloquence on the subject is worthy of praise – as we all have to acknowledge, the flag has always represented more than just ancestral pride. (Applause.) For many, black and white, that flag was a reminder of systemic oppression and racial subjugation. We see that now.

Removing the flag from this state’s capitol would not be an act of political correctness; it would not be an insult to the valour of Confederate soldiers. It would simply be an acknowledgment that the cause for which they fought – the cause of slavery – was wrong. The imposition of Jim Crow after the Civil War, the resistance to civil rights for all people, was wrong. It would be one step in an honest accounting of America’s history; a modest but meaningful balm for so many unhealed wounds. It would be an expression of the amazing changes that have transformed this state and this country for the better, because of the work of so many people of goodwill, people of all races striving to form a more perfect union. By taking down that flag, we express God’s grace.

But I don't think God wants us to stop there. (Applause.) For too long, we’ve been blind to the way past injustices continue to shape the present. Perhaps we see that now. Perhaps this tragedy causes us to ask some tough questions about how we can permit so many of our children to languish in poverty, or attend dilapidated schools, or grow up without prospects for a job or for a career.

Perhaps it causes us to examine what we’re doing to cause some of our children to hate. (Applause.) Perhaps it softens hearts towards those lost young men, tens and tens of thousands caught up in the criminal justice system – and lead us to make sure that that system is not infected with bias; that we embrace changes in how we train and equip our police so that the bonds of trust between law enforcement and the communities they serve make us all safer and more secure.

Maybe we now realise the way racial bias can infect us even when we don't realise it, so that we're guarding against not just racial slurs, but we're also guarding against the subtle impulse to call Johnny back for a job interview but not Jamal. So that we search our hearts when we consider laws to make it harder for some of our fellow citizens to vote. By recognising our common humanity by treating every child as important, regardless of the colour of their skin or the station into which they were born, and to do what’s necessary to make opportunity real for every American – by doing that, we express God’s grace.

For too long, for too long, we’ve been blind to the unique mayhem that gun violence inflicts upon this nation. Sporadically, our eyes are open: When eight of our brothers and sisters are cut down in a church basement, 12 in a movie theatre, 26 in an elementary school. But I hope we also see the 30 precious lives cut short by gun violence in this country every single day; the countless more whose lives are forever changed – the survivors crippled, the children traumatised and fearful every day as they walk to school, the husband who will never feel his wife’s warm touch, the entire communities whose grief overflows every time they have to watch what happened to them happen to some other place.

The vast majority of Americans – the majority of gun owners – want to do something about this. We see that now. And I'm convinced that by acknowledging the pain and loss of others, even as we respect the traditions and ways of life that make up this beloved country – by making the moral choice to change, we express God’s grace.

We don’t earn grace. We're all sinners. We don't deserve it. But God gives it to us anyway. And we choose how to receive it. It's our decision how to honour it.

None of us can or should expect a transformation in race relations overnight. Every time something like this happens, somebody says we have to have a conversation about race. We talk a lot about race. There’s no shortcut. And we don’t need more talk. None of us should believe that a handful of gun-safety measures will prevent every tragedy. It will not. People of goodwill will continue to debate the merits of various policies, as our democracy requires – this is a big, raucous place, America is. And there are good people on both sides of these debates. Whatever solutions we find will necessarily be incomplete.

But it would be a betrayal of everything Reverend Pinckney stood for, I believe, if we allowed ourselves to slip into a comfortable silence again. (Applause.) Once the eulogies have been delivered, once the TV cameras move on, to go back to business as usual – that’s what we so often do to avoid uncomfortable truths about the prejudice that still infects our society. (Applause.) To settle for symbolic gestures without following up with the hard work of more lasting change – that’s how we lose our way again.

It would be a refutation of the forgiveness expressed by those families if we merely slipped into old habits, whereby those who disagree with us are not merely wrong but bad; where we shout instead of listen; where we barricade ourselves behind preconceived notions or well-practiced cynicism.

Reverend Pinckney once said, “Across the South, we have a deep appreciation of history – we haven’t always had a deep appreciation of each other’s history.” What is true in the South is true for America. Clem understood that justice grows out of recognition of ourselves in each other. That my liberty depends on you being free, too. That history can’t be a sword to justify injustice, or a shield against progress, but must be a manual for how to avoid repeating the mistakes of the past – how to break the cycle. A roadway toward a better world. He knew that the path of grace involves an open mind – but, more importantly, an open heart.

That’s what I’ve felt this week – an open heart. That, more than any particular policy or analysis, is what’s called upon right now, I think – what a friend of mine, the writer Marilyn Robinson, calls “that reservoir of goodness, beyond, and of another kind, that we are able to do each other in the ordinary cause of things.”

That reservoir of goodness. If we can find that grace, anything is possible. If we can tap that grace, everything can change. Amazing grace. Amazing grace.

Amazing grace, how sweet the sound, that saved a wretch like me; I once was lost, but now I’m found; was blind but now I see.

Clementa Pinckney found that grace.

Cynthia Hurd found that grace.

Susie Jackson found that grace.

Ethel Lance found that grace.

DePayne Middleton-Doctor found that grace.

Tywanza Sanders found that grace.

Daniel L Simmons, Sr. found that grace.

Sharonda Coleman-Singleton found that grace.

Myra Thompson found that grace.