Cameron was responding to a letter from British actor and writer Stephen Fry, who called for the 2014 Winter Games to be taken away from Sochi because of a new Russian law that bans "propaganda of nontraditional sexual relations'' and imposes fines on those holding gay pride rallies.
Fry's letter asked Cameron and International Olympic Committee executives not to give President Vladimir Putin "the approval of the civilized world'' and called for an "absolute ban'' on the Olympics being staged in Russia.
The British prime minister thanked Fry for his note, saying on Twitter that he shares Fry's "deep concern about the abuse of gay people in Russia.''
"I believe we can better challenge prejudice as we attend, rather than boycotting the Winter Olympics,'' Cameron said.
Cameron's words echoed remarks made a day earlier by President Barack Obama, who said he was deeply offended by Russia's new law cracking down on gay rights activism but does not think it is "appropriate'' to boycott the Olympics.