An abnormal phenomenon may occur during gas-well testing: the wellhead pressure initially rises and then drops when shutting-in a well; the wellhead pressure initially drops and then rises when opening a well. To determine why and how this phenomenon occurs, a transient nonisothermal wellbore flow model for gas-well testing is developed. Governing equations are based on depth- and time-dependent mass, momentum equations, and the gas state equation. Temperature is predicted using the unsteady-state heat transfer model of Hasan. Boundary conditions include the restriction of formation inflow and wellhead throttling to the flow. The difference equations are established based on the implicit central finite difference method. The model can simulate the influences of temperature and flux (mass velocity). The model also considers the effects of formation inflow and surface throttling on the system. The results indicate wellhead pressure under flowing temperature is higher than that under static temperature, thus causing the abnormal phenomenon. A larger pressure difference makes the abnormal phenomenon more significant. Without considering temperature variation, simulated wellhead pressure would not exhibit the abnormity. Without considering flux variation, simulated pressure curve is not smooth. A new model has thus been validated using a gas field example.