BACKGROUNDHepatitis E virus (HEV) leads to high mortality in pregnant women in low-income countries. We aimed to evaluate the safety of a HEV vaccine and its effectiveness in preventing hepatitis E during pregnancy.METHODSIn this phase 4, double-blind, cluster-randomised trial, 67 villages in Matlab, Bangladesh, were randomised 1:1 to receive HEV239 (a recombinant HEV vaccine) or a control vaccine (Hepa-B, a hepatitis B vaccine), using block randomisation with random number tables and blocks of size eight, stratified by cluster population size. Eligible non-pregnant women (aged 16-39 years) were vaccinated intramuscularly on day 0, at 1 month, and at 6 months, and followed up for 2 years after the last immunisation. The primary endpoint was hepatitis E in the pregnant, per-protocol population (those who received all three doses within 2 days of the scheduled dates), while safety was a secondary endpoint, assessed in the intention-to-treat (ITT) population (participants who received at least one dose). Solicited adverse events were recorded for the first 7 days after each dose, and unsolicited events until 2 years after a participant's final dose. Pregnancy-related safety outcomes were assessed in the pregnant ITT population. This study is registered with ClinicalTrials.gov (NCT02759991).FINDINGSBetween Oct 2, 2017, and Feb 28, 2019, 19 460 participants were enrolled and received either HEV239 (9478 [48·7%] participants, 33 clusters) or Hepa-B (9982 [51·3%] participants, 34 clusters), of whom 17 937 (92·2%) participants received three doses and 17 613 (90·5%) were vaccinated according to protocol (8524 [48·4%] in the HEV239 group and 9089 [51·6%] in the control group). No pregnant participants were confirmed to have hepatitis E in either treatment group. HEV239 showed a mild safety profile, similar to Hepa-B, with no difference in the proportion of solicited adverse events between groups and no severe solicited events. Pain was the most common local symptom (1215 [12·8%] HEV239 recipients and 1218 [12·2%] Hepa-B recipients) and fever the most common systemic symptom (141 [1·5%] HEV239 recipients and 145 [1·5%] Hepa-B recipients). None of the serious adverse events or deaths were vaccine related. Among pregnant participants, the HEV239 group had a higher risk of miscarriage (136 [5·7%] of 2407 pregnant participants) compared with the control group (102 [3·9%] of 2604; adjusted odds ratio 1·54 [95% CI 1·15-2·08]).INTERPRETATIONThe effectiveness of HEV239 in pregnant women remains uncertain. HEV239 was safe and well tolerated in non-pregnant women, but findings regarding miscarriage warrant further investigation.FUNDINGResearch Council of Norway; Innovax.