BackgroundThe relationship between air pollution and atrial fibrillation (AF) recorded by electrocardiograph (ECG) has not yet been illustrated which worsens AF precaution and treatment. This research evaluated the association between air pollution and daily hospital visits for AF with ECG records.MethodsThe study enrolled 4933 male and 5392 female patients whose ECG reports indicated AF from 2015 to 2018 in our hospital. Such data were then matched with meteorological data, including air pollutant concentrations, collected by local weather stations. A case-crossover study was performed to assess the relationship between air pollutants and daily hospital visits for AF recorded by ECG and to investigate its lag effect.ResultsOur analysis revealed statistically significant associations between AF occurrence and demographic data, including age and gender. This effect was stronger in female (k= 0.02635,p< 0.01) and in patients over 65 y (k= 0.04732,p< 0.01). We also observed a hysteretic effect that when exposed to higher nitrogen dioxide(NO2), counting AF cases recorded by ECG may elevate at lag 0 with a maximum odds ratio(OR) of 1.038 (95% CI 1.014–1.063), on the contrary, O3reduced the risk of daily visits for AF and its maximum OR was at lag 2, and the OR value was 0.9869 (95% CI 0.9791–0.9948). Other air pollutants such as PM2.5, PM10, and SO2showed no clear relationship with the recorded AF.ConclusionThe associations between air pollution and AF recorded with ECG were preliminarily discovered. Short-term exposure to NO2was significantly associated with daily hospital visits for AF management.Supplementary InformationThe online version contains supplementary material available at 10.1186/s40001-023-01170-y.