Low drug adherence is a major obstacle to the benefits of pharmacotherapies and it is therefore important to identify factors associated with discontinuing or being poorly adherent to a prescribed treatment regimen. Using high-quality nationwide health registry data and genome-wide genotyping, we evaluate the impact of socio-demographic and genetic risk factors on adherence and persistence for 5 common medication classes that require long-term, regular therapy (N = 1,814,591 individuals from Finnish nationwide registries, 217,005 with genetic data from Finland and Estonia). Need for social assistance and immigration status show a notable negative effect on persistence and adherence across the examined medications (odd ratios between 0.48 and 0.82 for persistence and between 1.1% to 4.3% decrease in adherence) while demographic and health factors show comparably modest or inconsistent effects. A genome-wide scan does not identify genetic variants associated with the two phenotypes, while some pharmacogenes (i.e. CYP2C9 and SLCO1B1) are modestly associated with persistence, but not with adherence. We observe significant genetic correlations between medication adherence and participation in research studies. Overall, our findings suggest that socio-economically disadvantaged groups would benefit from targeted interventions to improve the dispensing and uptake of pharmacological treatments.