Exposure to low and high ambient daily temperature has been associated with cardiovascular diseases. However, the hourly association, which may enable a more precise healthcare response, has rarely been explored. This study conducted a time-stratified case-crossover analysis of emergency patients with acute chest pain at the Chest Pain Center (CPC) in Foshan, China from 2018 to 2023. We employed a conditional logistic regression model coupled with a distributed lag non-linear model (DLNM) to evaluate the hourly exposure-lag-response associations with adjustment for potential confounding factors. A total of 17,634 emergency patients with acute chest pain were recorded in this study. We found that cold exposure was significantly associated with the risk of cardiac chest pain (CCP) onset within 0-144 h prior to onset. The odds ratios (ORs) of CCP onset were 1.793 (95% CI: 1.345, 2.390) for cold air temperature (14.7 degrees C) and 1.772 (95% CI: 1.353, 2.320) for cold apparent temperature (13.9 degrees C), respectively. Non-optimal temperatures exposure, particularly heat, was associated with an elevated risk of non-cardiac chest pain (NCCP) onset, with the highest cumulative risk occurring at a lag of 72 h, and the corresponding ORs were 2.368 (95% CI: 1.374, 4.082) for air temperature and 2.107 (95% CI: 1.334, 3.327) for apparent temperature. This study reveals the positive association between hourly temperature and the onset of the acute chest pain. These findings highlight the importance of positive measures, such as enhancing timely temperature alert systems and optimizing medical resource allocation.