This paper discussed the prediction of the equatorial ionospheric F2 layer critical frequencies, foF2, using a backpropagation neural network (BPNN) model in conjunction with a particle swarm optimization (PSO) algorithm, named as the BPNN–PSO model, for various solar and geomagnetic activities, and compared it with the IRI-2016 model. The critical frequency data were taken from an ionosonde located at Universiti Tun Hussein Onn Malaysia in Johor, Malaysia (1.86° N, 103.80° E). The model’s outputs were analyzed using root-mean-square error (RMSE). The BPNN–PSO model outperformed the IRI-2016 model during low, medium, and high solar activity. The BPNN–PSO model had the lowest RMSE of 0.20 MHz and performed best during periods of high solar activity. This is much better than the RMSE for IRI-2016 model, which was 2.95 MHz. In addition, compared with the IRI-2016 model, the BPNN–PSO model made accurate predictions during both quiet and geomagnetic storm conditions. The BPNN–PSO model had the lowest RMSE of 0.54 MHz during an intense storm, while the IRI-2016 model had the RMSE of 2.84 MHz during this storm.