The real-world efficacy of epidermal growth factor receptor (EGFR)-tyrosine kinase inhibitors (TKIs) in patients with advanced non-small cell lung cancer (NSCLC) harboring EGFR-activating mutations remains unclear. We conducted a retrospective cohort study using data from the claims database of Taipei Veterans General Hospital to perform direct comparisons of these three EGFR-TKIs (gefitinib, erlotinib, and afatinib) combined with co-medications (metformin, statins, antacids, and steroids). Stage IIIB and IV NSCLC patients with EGFR mutations receiving EGFR-TKIs as first-line treatment for > 3 months between 2011 and 2016 were enrolled. The primary endpoint was time to treatment failure (TTF). Patients who had received co-medications (≥ 28 defined daily doses) in the first 3 months of EGFR-TKI therapy were assigned to co-medications groups. A total of 853 patients treated with gefitinib (n = 534), erlotinib (n = 220), and afatinib (n = 99) were enrolled. The median duration of TTF was 11.5 months in the gefitinib arm, 11.7 months in the erlotinib arm, and 16.1 months in the afatinib arm (log-rank test, P < 0.001). After adjustments, afatinib showed lower risk of treatment failure compared with gefitinib (hazard ratio [HR] 0.54, 95% confidence interval [CI] 0.41–0.71) and erlotinib (HR 0.62, 95% CI 0.46–0.83). The risk of treatment failure in patients treated with EGFR-TKIs who received concomitant systemic glucocorticoid therapy was higher than in those treated with EGFR-TKI monotherapy (HR 1.47, 95% CI 1.08–2.01). Afatinib or erlotinib use was associated with a lower risk of treatment failure in patients with advanced NSCLC harboring EGFR mutations compared to gefitinib use. Concurrent use of systemic glucocorticoids was linked to higher risk of treatment failure.