In the twilight of his presidency, Barack Obama is embracing the difficult work of moving Americans away from a new era of racial tension and toward reconciliation.
For Mr. Obama, the country's first black president, it is a bitter final challenge.
On Tuesday, Mr. Obama travelled to Dallas to attend an interfaith memorial for the five police officers killed by a gunman last week during a protest against police brutality.
His role was not simply to act as the country's consoler-in-chief, a responsibility he has assumed many times following incidents of deadly violence. He came to begin the task of repairing a country divided after the shootings in Dallas and the deaths of two African-American men in Minnesota and Louisiana at the hands of police officers.
"The deepest fault lines of our democracy have suddenly been exposed, perhaps even widened," Mr. Obama said on Tuesday. "We wonder if the divides of race in America can ever be bridged."
In often starkly personal terms, Mr. Obama rejected despair and appealed for empathy. "America, we know that bias remains," he said. "We've heard it at times in our own homes. If we're honest, perhaps we've heard prejudice in our own heads and felt it in our own hearts."
"Can we see in each other a common humanity and a shared dignity and recognize how our different experiences have shaped us?" he asked. "I don't know. I confess that sometimes I, too, experience doubt."
He spoke pointedly of the challenges faced by police officers. "So much of the tensions between police departments and the minority communities that they serve is because we ask the police to do too much and we ask too little of ourselves."
In some areas, there are "so many guns that it's easier for a teenager to buy a Glock than get his hands on a computer," Mr. Obama said. "Then we tell the police … to keep those neighbourhoods in check at all costs and do so without causing any political blowback or inconvenience."
He called out excesses on both sides of the current debate over police brutality. "Insisting that we do better to root out racial bias is not an attack on cops, but an effort to live up to our highest ideals," he said. "Even those who dislike the phrase 'Black Lives Matter' … should be able to hear the pain of Alton Sterling's family." Mr. Sterling was shot by police officers in Louisiana last week after being wrestled to the ground.
Mr. Obama also had strong words for some of those protesting police conduct. "When anyone, no matter how good their intentions may be, paints all police as biased or bigoted, we undermine those officers that we depend on for our safety." He urged the rejection of "the overheated rhetoric," which "reduces whole categories of fellow Americans [to] not just opponents but to enemies."
It is a tightrope act that is all too familiar to Mr. Obama – and it is likely to earn him criticism in certain quarters. For some African-Americans, he has been too hesitant and not outspoken enough on the issues impacting their community. Meanwhile, a growing chorus of right-wing voices has portrayed him as anti-police.
As President, he has discussed the country's racial divide only rarely and with an abundance of caution. When Trayvon Martin, an African-American teenager, was shot and killed by a neighbourhood-watch volunteer while walking home from a convenience store in 2012, Mr. Obama was pressed to respond.
"If I had a son, he'd look like Trayvon," he said. "When I think about this boy, I think about my own kids." But the President did not explicitly mention race in any way. More than a year later, after his re-election, he spoke at greater length about Mr. Martin's death and his own experiences with racial profiling – being followed while shopping in a department store, or hearing the locks on car doors click as he approached.
When Mr. Obama does tackle the topic of race in America, he has shown an unparalleled ability to empathize with the concerns of both black and white Americans. Perhaps the most memorable speech he has delivered came in 2008, when, as a presidential candidate, he spoke in frank terms about the African-American experience.
However, the "post-racial" society predicted by some after Mr. Obama's historic election feels more than ever as a cruel mirage. Instead, surveys show that the American public's view of race relations is more negative now than it was during the first six years of his presidency, according to a recent report from the Pew Research Center.
A poll conducted by the centre in May found that 34 per cent of Americans believe that Mr. Obama has made progress in improving race relations, while 28 per cent say he has tried to improve things but failed. Another 25 per cent believed he has made race relations worse. Among white Republicans, 63 per cent shared that view.
On Tuesday, he was joined by former president George W. Bush, who lives in Dallas. In his remarks at the memorial for the officers, Mr. Bush also called for unity: "Too often we judge other groups by their worst examples while judging ourselves by our best intentions."
Mr. Obama concluded with a note of tempered hope. The gunman who opened fire in Dallas "won't be the last person who makes us try to turn on one another," he said. "As we get older, we learn we don't always have control of things, not even a president does. But we do have control over how we respond to the world. We do have control over how we treat one another."