Abstract Superconducting materials inevitably suffer from the sudden change of temperature in localized areas in practical applications, and the concomitant thermal gradient may be detrimental to their performance. Critical current density is a key factor affecting the performance of superconductors. However, the effect of thermal gradient on the critical current density has not been identified. Here, by combining the time-dependent Ginzburg–Landau equations and the heat transfer equation, the thermal gradient and magnetic field dependence of the critical current density are systematically investigated and rationalized by exploring the behavior of vortex and magnetization. For lower magnetic fields, it is found that the thermal gradients strongly reduce the local surface barriers, which inhibits vortex entry and movement, leading to a rapid deterioration of the current-carrying capability. Under moderate magnetic fields, the critical current density corresponding to higher thermal gradients decreases more slowly with increasing magnetic field, which results from the thermal gradient-induced entry and moving of vortices along the current direction. As the magnetic field continues to increase, the variation of the critical current density transitions into a platform period and even slightly rises. The enhanced critical current is primarily attributed to the excess entry of vortices, which increases the surface barrier of the sample. With the further increase in the magnetic field, the critical current density continues to decrease due to increased magnetic field penetration. These results unveil the fundamental interplay between thermal gradients, external magnetic field, vortex, magnetization and critical current density, and provide a theoretical basis for understanding the heat-induced quenching of mesoscopic superconducting thin films in practical applications.