Objective To evaluate if the intraoperative human papillomavirus (IOP-HPV) test has the same prognostic value as the HPV test performed at 6 months after treatment of high-grade squamous intraepithelial lesion (HSIL) to predict treatment failure. Design Prospective cohort study. Setting Barcelona, Spain. Population A cohort of 216 women diagnosed with HSIL and treated with loop electrosurgical excision procedure (LEEP). Methods After LEEP, an HPV test was performed using the Hybrid Capture 2 system. If this was positive, genotyping was performed with the CLART HPV2 technique. The IOP-HPV test was compared with HPV test at 6 months and with surgical margins. Main outcome measure Treatment failure. Results Recurrence rate of HSIL was 6%. There was a strong association between a positive IOP-HPV test, a positive 6-month HPV test, positive HPV 16 genotype, positive surgical margins and HSIL recurrence. Sensitivity, specificity, and positive and negative predictive values of the IOP-HPV test were 85.7, 80.8,24.0 and 98.8% and of the HPV test at 6 months were 76.9, 75.8, 17.2 and 98.0%. Conclusion Intraoperative HPV test accurately predicts treatment failure in women with cervical intraepithelial neoplasia grade 2/3. This new approach may allow early identification of patients with recurrent disease, which will not delay the treatment. Genotyping could be useful in detecting high-risk patients. Tweetable abstract IOP-HPV test accurately predicts treatment failure in women with CIN 2/3.