Urban form plays a critical role in enhancing urban climate resilience amidst the challenges of escalating global climate change and recurrent high-temperature heatwaves. Therefore, it is crucial to study the correlation between urban spatial form factors and land surface temperature (LST). This study utilized Landsat 8 remote sensing data to estimate LST. Random forest nonlinear analysis was employed to investigate the interaction between the urban heat island (UHI) and six urban morphological factors: building density (BD), floor area ratio (FAR), building height (BH), fractional vegetation coverage (FVC), sky view factor (SVF), and impervious surface fraction (ISF), within the framework of local climate zones (LCZs). Key findings revealed that Xi’an exhibited a significant urban heat island effect, with over 10% of the study area experiencing temperatures exceeding 40 °C. Notably, the average LST of building-class LCZs (1-6) was 3.5 °C higher than that of land cover-class LCZs (A-C). Specifically, compact LCZs (1-3) had an average LST 3.02 °C higher than open LCZs (4-6). FVC contributed the most to the variation in LST, while FAR contributed the least. ISF and BD were found to have a positive impact on LST, while FVC and BH had a negative influence. Moreover, SVF was observed to positively influence LST in the compact classes (LCZ2-3) and open low-rise class (LCZ6). In the open mid-rise class (LCZ5), SVF and LST showed a U-shaped relationship. There is an inverted U-shaped relationship between FAR and LST, with the inflection point occurring at 1.5. The results of nonlinear analysis were beneficial in illustrating the complex relationships between LST and its driving factors. The study’s results highlight the effectiveness of utilizing LCZ as a detailed approach to explore the relationship between urban morphology and urban heat islands. Recommendations for enhancing urban climate resilience include strategies such as increasing vegetation coverage, regulating building heights, organizing buildings in compact LCZs in an “L” or “I” shape, and adopting an “O” or “C” configuration for buildings in open LCZs to aid planners in developing sustainable urban environments.