Most successful existing vaccines rely on neutralizing antibodies, which may not require specific anatomical localization of B cells. However, efficacious vaccines that rely on T cells for protection have been difficult to develop, as robust systemic memory T-cell responses do not necessarily correlate with host protection. In peripheral sites, tissue-resident memory T cells provide superior protection compared to circulating memory T cells. Here we describe a simple and non-inflammatory vaccine strategy that enables the establishment of a protective memory T-cell pool within peripheral tissue. The female genital tract, which is a portal of entry for sexually transmitted infections, is an immunologically restrictive tissue that prevents entry of activated T cells in the absence of inflammation or infection. To overcome this obstacle, we developed a vaccine strategy that we term 'prime and pull' to establish local tissue-resident memory T cells at a site of potential viral exposure. This approach relies on two steps: conventional parenteral vaccination to elicit systemic T-cell responses (prime), followed by recruitment of activated T cells by means of topical chemokine application to the restrictive genital tract (pull), where such T cells establish a long-term niche and mediate protective immunity. In mice, prime and pull protocol reduces the spread of infectious herpes simplex virus 2 into the sensory neurons and prevents development of clinical disease. These results reveal a promising vaccination strategy against herpes simplex virus 2, and potentially against other sexually transmitted infections such as human immunodeficiency virus.