The calculation model is developed to evaluate the residual lifetime of a pipe with a crack considering in-service degradation of the pipeline steel and the effect of soil corrosion. The model is based on the first law of thermodynamics. The problem of determination of the period of subcritical crack growth in a pipe is reduced to the differential equation subjected to definite initial and final conditions. Obtained equation together with the boundary conditions are used for prediction of the residual lifetime of the pipe made of the X52 pipe steel. The pipe contains external surface semi-elliptical crack. The task consists in the determination of the time of crack propagation through the pipe wall till its decompression. According to the experimental data, cracks in the studied steel under long-term loading and soil corrosion propagate mainly at constant rate, which is different for the as-received pipeline steel and the steel after 30 years in service. Based on these data, the equation for approximate determination of the crack growth rate for arbitrary service time of the pipe made of the X52 steel is proposed. To evaluate the crack propagation time, the energy approach is employed. For a crack that remains semi-elliptical during propagation, the problem is reduced to the differential equation system that determines the variations of the crack semi-axes. The system solution under definite initial and final conditions renders the expression for the pipe residual lifetime. The dependences of pipe residual lifetime on initial crack depth and pipe operation time are derived. The strong influence of the time of steel previous service on the pipe residual lifetime is manifested.