The nation’s difficult history with race relations has been central to the narrative of Barack Obama’s rise to the presidency and has often complicated the ways in which he deals with the issue both as a candidate and as president.

But the president’s decision Friday to assertively insert himself into the controversy surrounding the fatal shooting of Trayvon Martin, a black Florida 17-year-old, is evidence of Obama’s evolution and rising comfort level in dealing with the matter of race.

The new approach is at once deeply personal and completely universal, and avidly avoids taking sides in a political fight. His appeal Friday was to the parents. “I can only imagine what these parents are going through,” he said. “And I think every parent in America should be able to understand why it is absolutely imperative that we investigate every aspect of this, and that everybody pulls together — federal, state and local — to figure out exactly how this tragedy happened.”

Embedded in his remarks in the Rose Garden was a particular message about being a black parent.

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

It was rare for Obama to directly broach a subject that has caused him more political problems than benefit, but this was not another Obama race speech or his off-the-cuff comments about the arrest of a black Harvard professor in 2009.

White House officials almost certainly knew Obama would be asked about the Martin shooting soon. The case has stirred immense passion nationwide because of its racial element: Martin, who was unarmed, was killed by George Zimmerman, 28, a Hispanic neighborhood watch volunteer, who told police that he shot the black teenager in self-defense. Zimmerman has not been charged in Martin's death. Obama did not deal with the details of the incident, managing to discuss the racially charged incident with deep emotion without saying the words “black” or “race.”

His remarks followed the announcement of his pick to lead the World Bank, not a time when he usually takes questions, but clearly he was ready for one. It was not apparent earlier that Obama would get involved in the controversy. It is the kind of issue that Obama and his aides have bungled in the past. But on Friday, even Republicans running for president followed him into the issue, echoing his call for a full investigation into the case.

White House aides had said repeatedly that they had no comment, calling it a local issue that needed to work its way through the courts. When the Justice Department opened a federal investigation into the case Monday night, senior White House officials kept quiet.

But all the while, according to White House press secretary Jay Carney, Obama was reading news stories about the case. Top Justice Department officials had informed White House aides in recent days that it wasn’t improper for the president to speak out about the ongoing investigation into Martin’s shooting, according to a government official with knowledge of those conversations.

The Rev. Al Sharpton, an Obama ally who led a rally attended by thousands Thursday night at a park in Sanford, Fla., the city where Martin was killed, said he thought it was important for the president to comment.

“It really brings home to people that this kid is not some potential thug in a hoodie,” said Sharpton, who said he had been in touch with the Justice Department but not Obama in recent days. “It brings home the potential of who the son could have been rather than how he was treated.”

Benjamin Crump, the attorney for Martin’s parents, Sybrina Fulton and Tracy Martin, described his clients as humbled by Obama’s comments and struck by physical similarities between their son and the president.

“How can we thank him?” Crump said they wanted to know.

Obama’s comments and his approach to the Florida shooting varied greatly from his handling of a similarly racially charged issue early on in his administration: the arrest by a white police officer of his friend and Harvard scholar Henry Louis Gates Jr., who is black.

Asked at a news conference in 2009 about the incident — which, at the time, had been dominating the headlines — Obama said police had “acted stupidly” in arresting Gates. His remarks created a political furor.

Law enforcement groups were angry that Obama commented even as he admitted that he did not know the details of the case. Civil rights groups sought to use the president’s comments to create a national conversation on racial profiling.

Within days, Obama had to retract his statement and later invited both the police officer and Gates to the White House for a beer. Both liberal activists and political strategists generally panned the meeting, which was awkwardly called “the beer summit,” saying it achieved nothing.

Calling Obama’s response to the Gates arrest “a disaster for the president” because he passed judgment on what had happened, Ari Fleischer, who served as press secretary for President George W. Bush, said Obama’s message Friday was a welcome contrast.

“There really is an issue of whether if you are black in America today, if you are dressed the way you are dressed, that that can make you a victim,” Fleischer said. “These are society’s most delicate issues, and I thought the president handled it delicately.”

Navigating race has been a complicated and layered task for Obama and his aides. He has spoken of race primarily in terms of the nation’s history and progress rather than current events. At the same time, he has not shied away from embracing his unique role in reflecting the history of blacks in the nation. When he sings in public, he chooses Al Green’s “Let’s Stay Together” and does it on stage at the Apollo Theater in Harlem, and he has been praised by black radio hosts for his willingness to call into their shows.

Obama hit the right notes Friday, said NAACP President Benjamin Jealous, who was one of the activists calling on Obama to speak out about the Martin case, saying, “Obama’s words spoke both to the universal pain felt about this case, the specific pain felt by the family and the need for our nation to look at itself in the mirror.”

Florida state Sen. Arthenia Joyner, chair of the state’s legislative black caucus, said the president sent a clear message. “I’m old enough to remember the Ku Klux Klan marching through the street,” Joyner said. “My perception of this man, who is our president, is that he gets it at every level.”

Obama’s calibrated answer first deftly avoided commenting on law enforcement or judging the actions of the shooter. He made clear that he did not want to step on the legal process started by Attorney General Eric H. Holder Jr. but was not at all reticent to talk about the victim and his family, saying that his main message was to Martin’s parents.

“I think they are right to expect that all of us as Americans are going to take this with the seriousness it deserves, and that we’re going to get to the bottom of exactly what happened,” he said.

Staff writers Sari Horwitz and Hamil Harris contributed to this report.