Barack Obama has urged Americans to “soundly reject language” from any leader that “feeds a climate of fear and hatred or normalises racist sentiments”.
He did not mention President Donald Trump directly in his first public statement since a pair of mass shootings in Texas and Ohio, but he reminded Americans that “we are not helpless” in the face of a spate of mass shootings.
“Until all of us stand up and insist on holding public officials accountable for changing our gun laws, these tragedies will keep happening,” the former president wrote.
A shooting at a Walmart in El Paso, Texas, on Saturday killed 22 people, and a second shooting outside a crowded bar in Dayton, Ohio, early on Sunday killed nine people.
The suspect in the El Paso massacre posted a racist, anti-immigrant screed shortly before the attack, investigators say.
The motive of the Dayton gunman, who died in the attack, is not yet clear.
Mr Obama, like many presidents before him, has avoided pointed criticism of his successor.
But his comments left little doubt that he was referring to Mr Trump, who has spoken disparagingly about immigrants, calling them rapists and murderers, and has hit out an "invasion" at the Mexico border.
Mr Trump has previously tempered his criticism of white supremacy, although he said in scripted remarks to the nation earlier on Monday that the nation “must condemn racism, bigotry and white supremacy”.
He also said he had directed the FBI to examine steps to identify and address domestic terrorism.
Mr Obama noted that the El Paso shooting followed a trend of “troubled individuals who embrace ideologies and see themselves obligated to act violently to preserve white supremacy”.
He advised Americans to also denounce the language of “leaders who demonise those who don’t look like us, or suggest that other people, including immigrants, threaten our way of life, or refer to other people as subhuman”.
Such language has “been at the root of most human tragedy throughout history”, he added, and has “no place in our politics and our public life”.