The thermal stress near the wellbore occurs because the temperature near the wellbore is changed by mud in well. The stress distribution near the wellbore is changed by the thermal stress, Eventually, the wellbore stability is affected. So, in this paper, first the integral equations of the thermal stress caused by varied temperature near the wellbore are derived from the thermoelastic theory. Then, the numerical computation is conducted for the thermal stress equations with the numerical results simulated for the temperature field near the hole. The plots of radius thermal stress distribution is obtained as a function of time. Further, the thermal stress is stacked with the pure mechanical stress near wellbore. Finally, the effect of the thermal stress on the wellbore stability is analyzed by use of the Mohr-Coulumb criterion for the any drilling condition and any time. The simulated result shows that the tangential and axial thermal stress on the holel formation interface may make the total effective stress to decrease on it below some point of section, and make the total effective stress to increase up some point. It is an important influence on the stress distribution near the wellbore. Therefore, the theories and simulated results in this paper have a guiding signification for the wellbore stability in the high temperature well and for the recovery of the production, such as the fracturing, injection, and thermal production.