The picture of Mr. Obama was taken by the White House photographer at the time, Pete Souza, on June 9, 2011, at a day care facility in Bethesda, Md., near where Mr. Obama’s younger daughter, Sasha, had just participated in her fourth-grade closing ceremony.

Mr. Obama’s supporters were often grateful for his emotional responses to moments of national tragedy. Those included his tearful speech years after the fact as he recalled the killings of children in Newtown, Conn., and his singing of “Amazing Grace” while eulogizing the reverend of a church in Charleston, S.C., who was one of nine parishioners killed by a white gunman motivated by racist hatred.

His tweet provided a contrast to President Trump’s equivocal responses to the protests in Charlottesville. The protests developed out of a rally organized by white nationalists and resulted in the death of one counterprotester. Mr. Trump, in his early response to the episode, condemned the violence on “many sides.”

Mr. Obama’s tweet passed Ms. Grande’s on the same day that Mr. Trump repeated his criticism of “both sides” in Charlottesville in an impromptu question-and-answer session. His remarks stunned many politicians, media personalities and even members of his own staff. But they prompted cheers from his supporters on Fox News, as well as the prominent white supremacists David Duke and Richard Spencer.