Due to the F2 ionospheric layer’s ability to reflect radio waves, the foF2 critical frequency is essential since sudden irregularities can disrupt communication and navigation systems, affecting the weather forecast’s accuracy. This paper aims to develop accurate foF2 critical frequency prediction up to 24 hours ahead, focusing on mid and high latitudes, using the long short-term memory (LSTM) model covering the 24th solar cycle from 2008 to 2019. To evaluate the effectiveness of the proposed model, a comparative analysis is conducted with commonly referenced machine learning techniques, including linear regression, decision tree algorithms, and multilayer perceptron (MLP) using the Taylor diagram and error plots. The study involved five monitoring stations, different years with minimum and maximum solar activity, and prediction timeframes. Through extensive experimentation, a comprehensive set of outcomes is evaluated across diverse metrics. The findings conclusively established that the LSTM model has demonstrated superior performance compared to the other models across all stations and years. On average, LSTM is 1.2 times better than the second-best model (DT), 1.6 times as effective as the multilayer perceptron MLP, and three times more accurate than linear regression. The results of this research hold promise for increasing the precision of foF2-prediction, with potential implications for enhancing communication systems and weather forecasting capabilities.