Abstract Thermal stratification in solar thermal storages is used to improve the efficiency of solar heating systems because a high degree of thermal stratification in the storages increases the thermal performance of the systems. It has been demonstrated that better thermal stratification can be achieved by increasing the aspect ratio (height-to-width ratio) of the heat storage containers. However, a high-aspect-ratio design may lead to mechanical (structural) instability of the storage space because of its tall, narrow shape. Therefore, heat storage containers should be designed to provide good thermal performance, while considering the mechanical stability of the storage space. This is an important issue in the design of thermal energy storage (TES) spaces, particularly the underground rock caverns used for TES, because the stability of rock caverns depends largely on geomechanical factors, such as rock properties and in-situ stresses. To address this issue, we present a numerical approach for determining the aspect ratio of underground TES caverns that considers both thermal performance and mechanical stability. This approach is based on a thermal performance evaluation in terms of thermal stratification using heat transfer analysis and a mechanical stability assessment that calculates the factor of safety using finite element analysis combined with a shear strength reduction (SSR) method. The applicability of our approach is demonstrated in the preliminary design of a silo-shaped rock cavern used to store hot water for district heating. The results of the numerical analyses under various design conditions are presented and discussed in detail, and we propose an aspect ratio for the rock cavern.