Sexual conflict is ubiquitous across taxa. It often results in male harassment of females for mating opportunities that are costly for females, in some cases reducing reproductive success and increasing mortality. One strategy that females may employ to avoid sexual harassment is to segregate spatially from males. In fact, we do find sexual segregation in habitat use in species that have high levels of sexual conflict; however, the role of sexual harassment in driving such segregation remains poorly understood. Here, we demonstrate experimentally in a population of wild Trinidadian guppies Poecilia reticulata that male sexual harassment drives females into habitats that they otherwise do not prefer to occupy. In support of the social factors hypothesis for sexual segregation, which states that social factors such as harassment drive sexual segregation, this female behaviour leads to segregation of the sexes. In the presence of males, females actively select areas of high predation risk, but low male presence, and thus trade off increased predation risk against reduced sexual harassment.