Objectives: Our objective was to analyse effectiveness and safety of oral anticoagulants (OAC) for stroke prevention in non-valvular atrial fibrillation.Material and methods: Population-based cohort study including adults initiating oral anticoagulants, either direct oral anticoagulants (DOAC) or vitamin K antagonists (VKA), during 2011–2020.Data source: SIDIAP, capturing information from the electronic health records of Primary Health Care in Catalonia, Spain.Study outcomes: stroke, cerebral and gastrointestinal (GI) haemorrhage, assessed by patients’ subgroups according to different clinical characteristics.Results: We included 90,773 patients. Male sex, older than 75, previous event, peripheral artery disease, deep vein thrombosis, or receiving antiplatelets, antidiabetics or proton pump inhibitors (PPI) was associated with higher stroke risk. For DOAC-treated, treatment switch increased stroke risk, while being adherent had a protective effect. Men, antidiabetic treatment or a previous event increased the risk of cerebral bleeding. Receiving direct oral anticoagulants had a protective effect in comparison to vitamin K antagonists. For DOAC-treated, treatment switch increased, and adherence decreased the bleeding risk. Men, people with chronic kidney disease or a previous event posed an increased risk of gastrointestinal bleeding, whereas receiving PPI had a protective effect. For DOAC-treated, switch was associated with a higher bleeding risk.Conclusion: Being men, a previous event and DOAC-switch posed a higher risk for all study outcomes. direct oral anticoagulants had a protective effect against cerebral bleeding in comparison to vitamin K antagonists. Adherence to direct oral anticoagulants resulted in lower risk of stroke and cerebral bleeding. We found no differences in the risk of stroke and gastrointestinal bleeding when we compared direct oral anticoagulants vs. vitamin K antagonists.