Background Most previous studies of the use of cervical pessaries were either retrospective or case controlled and their results showed that this intervention might be a preventive strategy for women at risk of preterm birth; no randomised controlled trials have been undertaken. We therefore undertook a randomised, controlled trial to investigate whether the insertion of a cervical pessary in women with a short cervix identified by use of routine transvaginal scanning at 20-23 weeks of gestation reduces the rate of early preterm delivery. Methods The Pesario Cervical para Evitar Prematuridad (PECEP) trial was undertaken in five hospitals in Spain. Pregnant women (aged 18-43 years) with a cervical length of 25 mm or less were randomly assigned according to a computer-generated allocation sequence by use of central telephone in a 1:1 ratio to the cervical pessary or expectant management (without a cervical pessary) group. Because of the nature of the intervention, this study was not masked. The primary outcome was spontaneous delivery before 34 weeks of gestation. Analysis was by intention to treat. This study is registered with ClinicalTrials.gov, number NCT00706264. Findings 385 pregnant women with a short cervix were assigned to the pessary (n=192) and expectant management groups (n=193), and 190 were analysed in each group. Spontaneous delivery before 34 weeks of gestation was significantly less frequent in the pessary group than in the expectant management group (12 [6%] vs 51 [27%], odds ratio 0·18, 95% CI 0·08-0·37; p<0·0001). No serious adverse effects associated with the use of a cervical pessary were reported. Interpretation Cervical pessary use could prevent preterm birth in a population of appropriately selected at-risk women previously screened for cervical length assessment at the midtrimester scan.