5G positioning technology has become deeply integrated into daily life. However, in wireless signal propagation environments, there may exist non-line-of-sight (NLOS) conditions, which lead to signal blockage and subsequently hinder the provision of positioning services. To address this issue, this paper proposes an intelligent reflecting surface (IRS) NLOS time difference of arrival–angle of arrival (TDOA-AOA) localization (INTAL) algorithm. First, the algorithm constructs a system model for 5G IRS localization, effectively overcoming the challenges of positioning in NLOS paths. Then, by applying the multiple signal classification algorithm to estimate the time delay and angle, and using the Chan algorithm to obtain the user’s estimated coordinates, an optimization problem is formulated to minimize the distance between the estimated and actual coordinates. The tent–snake optimization algorithm is employed to solve this optimization problem, thereby reducing localization errors. Finally, simulations demonstrate that the INTAL algorithm outperforms the snake optimization (SO) algorithm and the gray wolf optimization (GWO) algorithm under the same conditions, reducing the localization error by 56% and 60% on average, respectively. Additionally, when the signal-to-noise ratio is 30 dB, the localization error of the INTAL algorithm is only 0.2968 m, while the errors for the SO and GWO algorithms are 0.6733 m and 0.7398 m, respectively. This further proves the significant improvement of the algorithm in terms of localization accuracy.