An advertising campaign featuring cartoon characters shaped like male genitalia encouraged more men to get tested for syphilis in San Francisco, according to a new study.

In the neighborhoods where the Health Penis ads ran on billboards and bus shelters, men who saw the comic strips were most likely to have been tested for the sexually transmitted disease, according to researchers from the city's Department of Public Health.

The health department sponsored the humorously risque ads between 2002 and 2005 to combat rising syphilis rates among gay and bisexual men.

Between 40 and 60 percent of survey respondents who were aware of the ads said they had been tested in the previous six months, department researchers reported Tuesday in the online journal Public Library of Science Medicine.

Although the campaign was not without controversy — an outdoor advertising company initially refused to post the spots — infection rates have since declined, officials said.

"We took a risk, and that risk paid off," said Jacqueline McCright, a sexually transmitted diseases services manager with the health department.

The campaign's success has inspired Seattle, Philadelphia, Los Angeles and Palm Springs, California, to use similar ads.