The financial markets are encountering uncertain conditions that are heightening their tail risk. This study analyzed eight stock market indices employing a neural network quantile regression methodology from 24 July 2017 to 22 August 2023. The findings demonstrated that the proposed model effectively estimated the tail risk by VaR and CoVaR of the sample indices of the Iranian stock market while considering oil and gold price fluctuations as risk factors. The results showed that the global crisis of the COVID-19 pandemic, which began in China in 2020, had significant impacts on global indices. However, the shock was relatively worse in the Iranian stock market, particularly in some industries such as Metals, Metal ores, and Chemicals, and the Overall indices had greater vulnerability than the rest of the indices. During the global crisis in 2022, which was triggered by the war in Ukraine, the Iranian capital market experienced a significant shock.