Cameron's comments were aimed at Sadiq Khan, a Muslim former government minister and human rights lawyer who is leading opinion polls for the May 5 mayoral election.
During Prime Minister's Questions in the House of Commons, Cameron accused Khan of appearing alongside imam Sulaiman Ghani on nine occasions.
"If we are going to condemn not just violent extremism but also the extremism that seeks to justify violence in any way, it is very important that we do not back these people and we do not appear on platforms with them," Cameron said.
A Muslim mayor for London?
The prime minister added that he was "concerned" about Khan, accusing him of appearing "again and again and again" with Ghani, saying: "This man supports IS."
Cameron's comments were interrupted by an uproar from Labour MPs, some of whom shouted "racist" at him.
Labour leader Jeremy Corbyn called the comments "disgraceful" while a Labour source said it "demeans the office of prime minister" to repeat such allegations.
Khan, the son of a bus driver who moved to Britain from Pakistan, accused Cameron's Conservatives of running a "nasty, dog-whistling campaign that is designed to divide London's communities".
Disappointed PM has joined @ZacGoldsmith’s divisive, dog-whistling campaign. I’ve fought extremism all my life #PMQs pic.twitter.com/tf0zKHZkTd
— Sadiq Khan (@SadiqKhan) April 20, 2016
He said on BBC television this week that his work as a human rights lawyer had brought him into contact with some extremists.
"I regret giving the impression I subscribe to their views. I have been quite clear that I find their views abhorrent," he said.
A Downing Street source said that Cameron had been raising an issue about Khan's "judgment" and rejected claims of racism as "complete nonsense".
An Opinium poll for the London Evening Standard newspaper this month gave Khan a clear lead with 35 per cent of first preference votes compared to 27 per cent for Zac Goldsmith, the candidate for Cameron's Conservative party.
The race to succeed Conservative Boris Johnson as London mayor has often been a bitter and charged one.
Last month, Goldsmith drew criticism for warning in a campaign leaflet targeted at British Indians that Khan did not attend a rally for Indian prime minister Narendra Modi in London last year and that Labour supported a tax on family jewellery.
COMMENTS (12)
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ