BACKGROUND: Pertussis vaccination in pregnancy is recommended in many countries to provide protection to young infants. The best timing for this vaccination is uncertain. In the UK, vaccination is recommended between 16 weeks and 32 weeks of gestation. In this trial we aimed to investigate the equivalence of three time periods for pertussis vaccination in pregnancy. METHODS: In this open-label, equivalence, randomised controlled trial to investigate equivalence of different time windows for pertussis vaccination in pregnancy, participants were randomly assigned (1:1:1 ratio) to receive a pertussis-containing vaccine (Boostrix-inactivated poliovirus vaccine) in one of three gestational age groups, comprising group 1 (≤23 weeks + 6 days), group 2 (24-27 weeks + 6 days), and group 3 (28-31 weeks + 6 days) using a computer-generated randomisation list. The primary outcome was concentration of pertussis-specific antibodies in the infant born at term at birth. Maternal blood sampling was done before and 2 weeks after vaccination and at delivery, together with a cord sample, and an infant sample was collected at least 4 weeks after primary vaccination. Reactogenicity was assessed for 7 days after vaccination. This trial was registered with ClinicalTrials.gov (NCT03908164). FINDINGS: Between May 7, 2019, and Feb 13, 2020, of 1010 women assessed for eligibility, 364 women were recruited and 351 received the intervention (120 in group 1, 119 in group 2, and 112 in group 3). Equivalence of time periods was demonstrated for anti-pertussis toxin and anti-pertactin IgG concentrations. The cord blood geometric mean concentrations of anti-filamentous haemagglutinin IgG were higher with increasing gestational age at vaccination, such that for infants in group 1 (≤23 weeks + 6 days), equivalence to group 3 (28-31 weeks + 6 days) was not shown. Reported rates of fever were similar between study groups. INTERPRETATION: Pertussis vaccination at three different time intervals in pregnancy resulted in equivalent concentrations of IgG antibodies in infants against two of the three pertussis antigens assessed. Overall, these findings support recommendations to vaccinate any time between 16 weeks and 32 weeks of gestation. FUNDING: The Thrasher Research Fund and the National Immunisation Schedule Evaluation Consortium through the National Institute for Health and Care Research policy research programme.