Background Azithromycin exposure has been reported to increase the risk of QT prolongation and cardiovascular death. However, findings on the association between azithromycin and cardiovascular death are controversial, and azithromycin is still used in actual practice. Additionally, quantitative assessments of risk have not been performed, including the risk of QT prolongation when patients are exposed to azithromycin in a real-world clinical setting. Therefore, in this study, we aimed to evaluate the risk of exposure to azithromycin on QT prolongation in a real-world clinical setting using a 21-year medical history database of a tertiary medical institution. Methods We analyzed the electrocardiogram results and relevant electronic health records of 402,607 subjects in a tertiary teaching hospital in Korea from 1996 to 2015. To evaluate the risk of QT prolongation of azithromycin, we conducted a case-control analysis using amoxicillin for comparison. Multiple logistic regression analysis was performed to correct for age, sex, accompanying drugs, and disease. Results The odds ratio (OR) for QT prolongation (QTc>450 ms in male and >460 ms in female) on azithromycin exposure was 1.40 (95% confidence interval [CI], 1.23-1.59), and the OR for severe QT prolongation (QTc>500 ms) was 1.43 (95% CI, 1.13-1.82). On the other hand, the ORs on exposure to amoxicillin were 1.06 (95% CI, 0.97-1.15) and 0.88 (95% CI, 0.70-1.09). In a subgroup analysis, the risk of QT prolongation in patients aged between 60 and 80 years was significantly higher when they are exposed to azithromycin. Conclusions The risk of QT prolongation was increased when patients, particularly the elderly aged 60-79 years, were exposed to azithromycin. Therefore, clinicians should pay exercise caution using azithromycin or consider using other antibiotics, such as amoxicillin, instead of azithromycin.