Without naming anyone, Obama said in a statement on Monday: "We should soundly reject language coming out of the mouths of any of our leaders that feeds a climate of fear and hatred or normalises racist sentiments; 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 sub-human, or imply that America belongs to just one certain type of people," the BBC reported.
"It has no place in our politics and our public life. And it's time for the overwhelming majority of Americans of goodwill, of every race and faith and political party, to say as much - clearly and unequivocally."
Obama's comments came after President Donald Trump sought to deflect criticism that his anti-immigrant rhetoric had fuelled violence.
In a statement from the White House also on Monday, Trump called for mental health gun control reforms; the death penalty for those who commit mass murder and more bi-partisan co-operation over gun laws.
"In one voice, our nation must condemn racism, bigotry and white supremacy," Trump said, adding "these sinister ideologies must be defeated. Hate has no place in America".
The leaders' statements came after 31 people were killed in two mass shootings that took place over the weekend in El Paso, Texas and Dayton, Ohio, the BBC reported.
The El Paso shooter, Patrick Crusius, has been arrested. He is believed to be the author of a document posted online before the shooting which said the attack at the Walmart on Saturday was "a response to the Hispanic invasion of Texas".
Trump is scheduled to visit El Paso on Wednesday.
In the early hours of Sunday, 24-year-old Connor Betts killed his sister and eight others in outside a nightclub in Dayton.
Betts was shot dead by police. Officials have not yet suggested a motive for the attack and police said on Monday it was unclear whether he had intended to kill his sister.
( With inputs from IANS )