The incidence and prevalence of dialysis in Taiwan are high compared to other regions. Consequently, mitigating chronic kidney disease (CKD) and the worsening of kidney function have emerged as critical healthcare priorities in Taiwan. Heat stress is known to be a significant risk factor for CKD and kidney function impairment. However, differences in the impact of heat stress between males and females remains unexplored. We conducted this retrospective cross-sectional analysis using data from the Taiwan Biobank (TWB), incorporating records of the wet bulb globe temperature (WBGT) during midday (11 AM–2 PM) and working hours (8 AM–5 PM) periods based on the participants’ residential address. Average 1-, 3-, and 5-year WBGT values prior to the survey year were calculated and analyzed using a geospatial artificial intelligence-based ensemble mixed spatial model, covering the period from 2010 to 2020. A total of 114,483 participants from the TWB were included in this study, of whom 35.9% were male and 1053 had impaired kidney function (defined as estimated glomerular filtration rate < 60 ml/min/1.73 m2). Multivariable analysis revealed that in the male participants, during the midday period, the 1-, 3-, and 5-year average WBGT values per 1 ℃ increase were significantly positively associated with eGFR < 60 ml/min/1.73 m2 (odds ratio [OR], 1.096, 95% confidence interval [CI] = 1.002–1.199, p = 0.044 for 1 year; OR, 1.093, 95% CI = 1.000–1.196, p = 0.005 for 3 years; OR, 1.094, 95% CI = 1.002–1.195, p = 0.045 for 5 years). However, significant associations were not found for the working hours period. In the female participants, during the midday period, the 1-, 3-, and 5-year average WBGT values per 1 ℃ increase were significantly negatively associated with eGFR < 60 ml/min/1.73 m2 (OR, 0.872, 95% CI = 0.778–0.976, p = 0.018 for 1 year; OR, 0.874, 95% CI = 0.780–0.978, p = 0.019 for 3 years; OR, 0.875, 95% CI = 0.784–0.977, p = 0.018 for 5 years). In addition, during the working hours period, the 1-, 3-, and 5-year average WBGT values per 1 ℃ increase were also significantly negatively associated with eGFR < 60 ml/min/1.73 m2 (OR, 0.856, 95% CI = 0.774–0.946, p = 0.002 for 1 year; OR, 0.856, 95% CI = 0.774–0.948, p = 0.003 for 3 years; OR, 0.853, 95% CI = 0.772–0.943, p = 0.002 for 5 years). In conclusion, our results revealed that increased WBGT was associated with impaired kidney function in males, whereas increased WBGT was associated with a protective effect against impaired kidney function in females. Further studies are needed to elucidate the exact mechanisms underlying these sex-specific differences.