President Barack Obama on Friday said a mass shooting at a black church in South Carolina exposed the "blight" of racism still present in America, and railed against critics who have accused him of politicizing a tragedy to talk about tougher gun laws.

Obama, speaking to the U.S. Conference of Mayors, said the murder of nine people at a historic black church in Charleston shows the need for vigilance against racism.

"The apparent motivations of the shooter remind us that racism remains a blight that we have to combat together," Obama said.