Barack Obama in Baltimore mosque
Muslim American community leaders sit for a roundtable discussion with U.S. President Barack Obama (2nd L) at the Islamic Society of Baltimore mosque in Catonsville, Maryland February 3, 2016. Reuters

President Barack Obama, making his first visit to a US mosque, said attacks against one faith are attacks against all faiths.

In an effort to dispel fears of American Muslims in the face of rising racial prejudice and portrayal of Muslim community as 'terrorists," Obama said Americans should not become "bystanders to bigotry."

Calling the unbridled political rhetoric of the Donald Trump kind 'inexcusable' the president said such talk should have no place in the country.

"We've heard inexcusable political rhetoric against Muslim-Americans that has no place in our country," the president said during his visit to the Islamic Society mosque in Baltimore.

Republican presidential candidate Donald Trump had called for a ban on Muslims entering the country while another GOP frontrunner Ted Cruz had said the country should focus on Judeo-Christian values.

"An attack on one faith is an attack on all our faiths ... When any religious group is targeted, we all have a responsibility to speak up," said the president, whose grandfather converted to Islam.

Obama also decried the negative representation of Muslims in popular culture. "Our television shows should have some Muslim characters that are unrelated to national security."

The President, a Christian, obliquely referred to a smear campaign against him suggesting he is a Muslim, saying founding father Thomas Jefferson was also attacked on those lines.

"Thomas Jefferson's opponents tried to stir things up by suggesting he was a Muslim, so I was not the first," Obama said, describing how Jefferson had specifically mentioned Muslims in the context of the American right to freedom of religion.

Obama, however, advised Muslim youths not to offer themselves a choice of either being a Muslim or a patriot.

"You fit in here. Right here ... You're not Muslim or American. You're Muslim and American."