One theory is that homosexual urges, when repressed out of shame or fear, can be expressed as homophobia. Freud famously called this process a “reaction formation” — the angry battle against the outward symbol of feelings that are inwardly being stifled. Even Mr. Haggard seemed to endorse this idea when, apologizing after his scandal for his anti-gay rhetoric, he said, “I think I was partially so vehement because of my own war.”

It’s a compelling theory — and now there is scientific reason to believe it. In this month’s issue of the Journal of Personality and Social Psychology, we and our fellow researchersprovide empirical evidence that homophobia can result, at least in part, from the suppression of same-sex desire.

Our paper describes six studies conducted in the United States and Germany involving 784 university students. Participants rated their sexual orientation on a 10-point scale, ranging from gay to straight. Then they took a computer-administered test designed to measure their implicit sexual orientation. In the test, the participants were shown images and words indicative of hetero- and homosexuality (pictures of same-sex and straight couples, words like “homosexual” and “gay”) and were asked to sort them into the appropriate category, gay or straight, as quickly as possible. The computer measured their reaction times.

The twist was that before each word and image appeared, the word “me” or “other” was flashed on the screen for 35 milliseconds — long enough for participants to subliminally process the word but short enough that they could not consciously see it. The theory here, known as semantic association, is that when “me” precedes words or images that reflect your sexual orientation (for example, heterosexual images for a straight person), you will sort these images into the correct category faster than when “me” precedes words or images that are incongruent with your sexual orientation (for example, homosexual images for a straight person). This technique, adapted from similar tests used to assess attitudes like subconscious racial bias, reliably distinguishes between self-identified straight individuals and those who self-identify as lesbian, gay or bisexual.

Using this methodology we identified a subgroup of participants who, despite self-identifying as highly straight, indicated some level of same-sex attraction (that is, they associated “me” with gay-related words and pictures faster than they associated “me” with straight-related words and pictures). Over 20 percent of self-described highly straight individuals showed this discrepancy.

Notably, these “discrepant” individuals were also significantly more likely than other participants to favor anti-gay policies; to be willing to assign significantly harsher punishments to perpetrators of petty crimes if they were presumed to be homosexual; and to express greater implicit hostility toward gay subjects (also measured with the help of subliminal priming). Thus our research suggests that some who oppose homosexuality do tacitly harbor same-sex attraction.

What leads to this repression? We found that participants who reported having supportive and accepting parents were more in touch with their implicit sexual orientation and less susceptible to homophobia. Individuals whose sexual identity was at odds with their implicit sexual attraction were much more frequently raised by parents perceived to be controlling, less accepting and more prejudiced against homosexuals.

It’s important to stress the obvious: Not all those who campaign against gay men and lesbians secretly feel same-sex attractions. But at least some who oppose homosexuality are likely to be individuals struggling against parts of themselves, having themselves been victims of oppression and lack of acceptance. The costs are great, not only for the targets of anti-gay efforts but also often for the perpetrators. We would do well to remember that all involved deserve our compassion.

Richard M. Ryan is a professor of psychology, psychiatry and education at the University of Rochester. William S. Ryan is a doctoral student in psychology at the University of California, Santa Barbara.