WASHINGTON — President Barack Obama’s history with the politics of race — his own, and the way it is lived in this country — has been both beneficial and vexing over the course of his public life.

Racial identity was at the heart of his best-selling memoir, commissioned after he was elected the first African American president of the Harvard Law Review.

It helped distinguish him from more experienced Democrats in the 2008 presidential primaries, then nearly doomed his candidacy after his close relationship with a provocative black pastor was revealed. Once in the White House, his race often appeared to be as much a burden for him as an asset.

Now as he confronts public anger about the acquittal of George Zimmerman for fatally shooting an unarmed black teenager, Obama is being challenged again to meet the unique demands that come with being the nation’s first African American president.

Obama’s handling of the verdict’s aftermath reflects some of the hard-learned lessons of the past four years. Rather than criticism, he has chosen a tone of consolation, avoiding the issue of race directly to help cool the country down.

On Sunday afternoon, Obama issued a short statement asking “every American to respect the call for calm reflection from two parents who lost their young son,” a 17-year-old named Trayvon Martin.

“And as we do, we should ask ourselves if we’re doing all we can to widen the circle of compassion and understanding in our communities,” he continued, citing gun violence rather than racial mistrust as a specific issue to be considered.

Obama chose to issue the written statement rather than address the nation on camera — an option White House officials say was never discussed. It is highly unusual for a president to comment on a specific court case, and even more rare to do so on camera.

But senior administration officials said the fact that he had done so previously in the Martin case — and that the verdict had prompted strong emotions — influenced the decision to say something in writing. Obama helped draft the statement, they said.

“It wasn’t assumed inside the White House that he would obviously do this,” said a senior administration official, who spoke on the condition of anonymity to discuss the decision. “But this was something he had spoken to personally, in a very personal way, last year. And it’s a story that the country was really following.”

Of all the “firsts” Obama has achieved, his role as the country’s first black president has never been one in which he has been entirely comfortable.

His political near-death experience in the 2008 Democratic primaries caused by his relationship with the Rev. Jeremiah Wright, a Chicago pastor whose angry sermons were tinged with racial grievance, haunted Obama as he entered office.

His message from the start was that he would be a president for all Americans, not just black Americans. He was unsentimental about his achievement.

“At the inauguration, I think there was justifiable pride on the part of the country that we had taken a step that had moved us beyond some of the searing legacies of racial discrimination in this country,” Obama said during a news conference a little more than two months after his swearing-in. “And that lasted about a day.”

Four months later, Obama for the first time joined the on-again, off-again national conversation about race as president, brusquely and to politically damaging effect.

Asked during a news conference about the arrest of Harvard University professor Henry Louis Gates Jr. at his home in Cambridge, Mass., Obama said the police had “acted stupidly.”

The star professor of the university’s African American studies program faced charges of disorderly conduct — later dropped — in a case that appeared to highlight the use of racial profiling in police work. Obama had worked on the issue as a state legislator in Illinois and as a U.S. senator.

But the new president’s standing among white voters declined almost immediately and, to some extent, has never recovered. He later called his comments “stupid” and invited Gates and Cambridge Police Sgt. James Crowley, who arrested the professor, to the White House for a beer to talk about the issue.

“The president wants to continue to take the temperature down,” Robert Gibbs, the White House press secretary at the time, said on the eve of what came to be called the beer summit.

Obama has written extensively about navigating white and black America from Chicago’s South Side to Harvard Law and beyond.

As president, he has sought to do the same, appealing to both white supporters and African Americans, whose expectations for his administration are perhaps the highest. He has argued that his policies are colorblind, from his various proposals to create jobs or those he has promoted unsuccessfully to better regulate gun purchases.

His black supporters have often asked for more attention given a higher unemployment rate and other problems among African Americans.

Obama has not always taken those complaints well. During a speech to the Congressional Black Caucus in September 2011, he unexpectedly admonished the audience, saying that “I expect all of you to march with me and press on.”

The next time he explicitly addressed race was in the days following the March 2012 shooting of Martin by Zimmerman, then a 28-year-old neighborhood watch volunteer in Sanford, Fla., who argued that he had acted in self defense. A jury in the case agreed last week.

As in the Gates arrest, reporters asked Obama last year about the Martin shooting. Only this time, in the midst of an election season, he was prepared.

“If I had a son, he’d look like Trayvon,” he said. “When I think about this boy, I think about my own kids.”

Obama did not mention race specifically in his comments that day in the Rose Garden, but as a black father his message was clear to those who wanted to hear it.

He also reserved judgement about the case itself, just as he did Sunday night about the verdict. A fuller response has been left largely to Attorney General Eric Holder Jr., who has often served as the president’s proxy on race matters.

Obama’s response to the Zimmerman verdict has satisfied some, but many African Americans would like to hear more from the first African American president.

As of now, White House officials say, that is unlikely to happen as the Justice Department considers a federal civil rights case against Zimmerman.

“We’re not going to get out ahead of that,” White House press secretary Jay Carney told reporters Tuesday. “Right now, the president views this as a tragedy, the loss of a young person — for his family, for the community and for the country.”

More in News

A wedding and special events’ planning business has agreed to pay a $200,000 settlement to five employees living in the country illegally after allegedly failing to pay them minimum wages and overtime and discriminating against them because of their race.

The CIA has concluded in a secret assessment that Russia intervened in the 2016 election to help Donald Trump win the presidency, rather than just to undermine confidence in the U.S. electoral system, according to officials briefed on the matter.