Sexual activities between consenting adults of the same sex are still criminalized in more than one third of the countries in the world despite a global wave of decriminalization in the past sixty years. This paper empirically investigates the effect of sex ratios, i.e. relative number of men to women, on the criminalization of same-sex sexual conducts. At the individual level, people in high sex ratio countries are found to be more hostile against homosexuality and the homosexuals than their counterparts in low sex ratio countries. At the country level, sex ratios have a positive effect on criminalization. In particular, the two-stage least squares estimate using temperature as instrumental variable suggests that adding another man per 100 women in a country would increase the probability of criminalization by nearly three percentage points. Moreover, the fixed-effect estimate based on a US state-level panel data show that adding another man per 100 women in a state would have lowered the probability of revoking the state sodomy law by nearly two percentage points. These findings suggest that a high sex ratio creates a homophobic social environment that facilitates (hampers) the criminalization (decriminalization) of homosexuality.