Aims: Our objectives were to compare effectiveness and long-term prognosis after epicardial thoracoscopic atrial fibrillation (AF) ablation vs. endocardial catheter ablation, in patients with prior failed catheter ablation or high risk of failure. Methods and results: Patients were randomized to thoracoscopic or catheter ablation, consisting of pulmonary vein isolation with optional additional lines (2007-2010). Patients were reassessed in 2016/2017, and those without documented AF recurrence underwent 7-day ambulatory electrocardiography. The primary rhythm outcome was recurrence of any atrial arrhythmia lasting >30 s. The primary clinical endpoint was a composite of death, myocardial infarction, or cerebrovascular event, analysed with adjusted Cox proportional hazard ratios (HRs). One hundred and 24 patients were randomized with 34% persistent AF and mean age 56 years. Arrhythmia recurrence was common at mean follow-up of 7.0 years, but substantially lower with thoracoscopic ablation: 34/61 (56%) compared with 55/63 (87%) with catheter ablation [adjusted HR 0.40, 95% confidence interval (CI) 0.25-0.64; P < 0.001]. Additional ablation procedures were performed in 8 patients (13%) compared with 31 (49%), respectively (P < 0.001). Eleven patients (19%) were on anti-arrhythmic drugs at end of follow-up with thoracoscopy vs. 24 (39%) with catheter ablation (P = 0.012). There was no difference in the composite clinical outcome: 9 patients (15%) in the thoracoscopy arm vs. 10 patients (16%) with catheter ablation (HR 1.11, 95% CI 0.40-3.10; P = 0.84). Pacemaker implantation was required in 6 patients (10%) undergoing thoracoscopy and 3 (5%) in the catheter group (P = 0.27). Conclusion: Thoracoscopic AF ablation demonstrated more consistent maintenance of sinus rhythm than catheter ablation, with similar long-term clinical event rates.