Abstract Study question What is the accuracy of an algorithm using Bayes' theorem for diagnosing ectopic pregnancy (EP) having hCG, ultrasound, and clinical data in a real cohort? Summary answer The accuracy of the algorithm is 98.9% (95%CI=98.4% to 99.3%) What is known already The Bayes' theorem describes the probability of an event after the input of prior knowledge of conditions that might be related to the event. Ectopic pregnancy has been diagnosed using clinical aspects, transvaginal ultrasound (TVUS) and serial measurement of hCGs Study design, size, duration The Bayes' theorem describes the probability of an event after the input of prior knowledge of conditions that might be related to the event. Ectopic pregnancy has been diagnosed using clinical aspects, transvaginal ultrasound (TVUS) and serial measurement of hCGs. Participants/materials, setting, methods First-trimester patients who attended the Gynaecologic Emergency Unit were included. Clinical signs and symptoms, the presence of risk factors for ectopic pregnancy (EP), ultrsound findings and hCG levels were independent variables. Pre-test probability, based on clinical presentation and risk factors, likelihood ratio (LR) of variable were calculated, yielding a post-test probability (PTP). EP was the main outcome. EP was excluded with PTP <1%, while a PTP ≥ 95% warranted a treatment. Main results and the role of chance The incidence of ectopic pregnancy was 8.5% (212/2495;95%CI=7.4% to 9.6%); 310 patients were excluded because they were submitted to surgery with decision thresholds <95%. The algorithm was applied in 2185 patients. Just one case remained inconclusive after 3 consultations, and it was considered as an error in prediction. The sensitivity, specificity, and accuracy values (95%CI) of the algorithm were 98.9% (96.1% to 99.8%), 98.9% (98.3% to 99.2%), and 98.9% (98.3% to 99.2%), respectively. Limitations, reasons for caution These results were based on a single centre, and β-hCG were measured using the 4th International Standard in Cobas HCG+ β Elecsys 2010 Modular Analytics E170 machine Wider implications of the findings An online and customizable algorithm was developed to be used by different centers Trial registration number not applicable