Abstract. The deep marine carbonate formation is one of the key areas of oil and gas resource exploration and development for the future, and the basic characters of these resources are HTHP, high content of sour gas and narrow mud density window. Sour gases (H 2 S or CO 2 ) are prone to invade into wellbore, leading to serious drilling accidents such as kick and blowout. Considering the sour gas solubility, phase transition and effects of temperature and pressure on the physical parameters of drilling fluid, a multiphase flow model for sour gas invasion is established, and a transient heat transfer and pressure coupling solving method is proposed to ensure the accuracy of numerical calculation. The results indicate that the annulus circulating temperature with H 2 S invasion is the highest, temperature with CO 2 comes second and CH 4 is the least. As gas solubility decreases and its phase transition near the wellhead, the volume of gas is expanded sharply and the gas phase volume fraction changes dramatically, which may lead to kick and blowout accidents instantly. When gas solubility is considered, a larger annular pressure could be got, and H 2 S has a larger influence on the annular pressure than CO 2 . Furthermore, the dissolved gas and annular pressure varying with different content of H 2 S or CO 2 in sour gas are calculated and analyzed. The research results may provide valuable theoretical guidance for the deep sour gas reservoir exploration and development.