Hemp (Cannabis sativa L.) has attracted global attention as a crop to grow in temperate and subtropical regions owing to its diverse primary and secondary metabolites. However, only limited information is available on how hemp responds to thermal stress and how this affects the cannabinoid content. In this study, we analyzed the major cannabinoid components [tetrahydrocannabinolic acid (THCA), cannabidiolic acid (CBDA), cannabidiol (CBD), and cannabinol (CBN)] in hemp using high-performance liquid chromatography. We evaluated cannabinoid contents in different organs, at different developmental stages, and under thermal stress conditions. Leaf discs collected from 75-day-old plants of three hemp cultivars were exposed to cold (4 degrees C) and heat stress (45 degrees C) conditions, with samples collected at various time points of 0, 6, 12, 24, and 48 hours. The highest cannabinoid concentrations occurred in the terminal flowers and leaves, and CBDA was the predominant cannabinoid in the 'Hot Blonde', 'Cherry Blossom', and 'Queen Dream' cultivars. In contrast, roots showed the lowest concentrations of the four cannabinoid compounds. After subjecting hemp plants to a temperature of 4 degrees C, no significant changes occurred in the levels of the four cannabinoid compounds; however, after a treatment at 45 degrees C, the contents of CBD and CBN increased in the Hot Blonde, Cherry Blossom, and Queen Dream cultivars, indicating an increase in decarboxylation due to the high temperature. We also examined the expression patterns of nine genes involved in cannabinoid biosynthesis in C. sativa L. and assessed the relationship between metabolic pathways and gene transcription. Overall, a positive correlation between cannabinoid biosynthesis and the expression of biosynthetic genes was observed. The transcription levels of the tetrahydrocannabinolic acid synthase (THCAS) and cannabichromenic acid synthase (CBCAS) genes gradually increased after a treatment at 45 degrees C, which aligned with the patterns observed for the CBD and CBN contents. These findings indicate that the high expression levels of THCAS and CBDAS under heat stress significantly influenced the accumulation of CBD and CBN at elevated temperatures. Our results provide a foundation for enhancing the content of functional components such as cannabinoids in hemp and for developing new medical hemp varieties.