In this work, a new method for nonlinear time-history earthquake analysis of 2D steel frames by a fiber plastic hinge method is presented. The beam-column element based on the displacement-based finite element method is established and formulated in detail using a fiber plastic hinge approach and stability functions. Geometric nonlinearities are taken into accounting by stability functions and the geometric stiffness matrix. A nonlinear dynamic algorithm is established based on the combination of the Newmark integration method and the Newton-Raphson iterative algorithm for solving dynamic equations. The proposed program predicts the nonlinear inelastic responses of 2D steel frames subjected to earthquakes as efficiently and accurately as commercial software. This study also shows that the initial residual stresses of steel should be considered in nonlinear inelastic time-history earthquake analysis of 2D steel frames while SAP2000 does not consider the effects of residual stresses.