Variability of response to medication is a well known phenomenon, determined by both environmental and genetic factors. Understanding the heritable component of the response to medication is of great interest but challenging due to several reasons, including small study cohorts and computational limitations. Here, we studied the heritability of variation in the glycaemic response to metformin, first-line therapeutic agent for type 2 diabetes (T2D), by leveraging 17 years of electronic health records (EHR) data from Israel’s largest healthcare service provider, consisting of over five million patients of diverse ethnicities and socio-economic background. Our cohort consisted of 74,871 T2D patients treated with metformin, with an accumulated number of 1,358,776 HbA1C measurements and 323,260 metformin prescriptions. We estimated the explained variance of glycated hemoglobin (HbA1c%) reduction due to heritability by constructing a six-generation population-size pedigree from national registries and linking it to medical health records. Using Linear Mixed Model-based framework, a common-practice method for heritability estimation, we calculated a heritability measure of h2 = 15.9% (95% CI, 1.2% − 30.5%) for absolute reduction of HbA1c% after metformin treatment in males and h2 = 20.9% (95% CI, 7.5% − 34.3%) in females. Results remained unchanged after adjusting for pre-treatment HbA1c% in females, and for both genders in proportional reduction of HbA1c%. To the best of our knowledge, our work is the first to estimate heritability of drug response using EHR data. We demonstrated that while response to metformin treatment has a heritable component, most of the variation is likely due to other factors, further motivating non-genetic analyses aimed at unraveling metformin’s mechanism of action.