The spatial and temporal harmonic balance (STHB) method is used to solve the periodic solution for a nonlinear partial dierential equation (PDE) demonstrated by a nonlinear string equation with a linear complex boundary condition, and stablity analysis is conducted for the periodic solutions using Hill's method. In order to avoid the integration procedure for discretizing the PDE to obtain the ordinary dierential equations (ODEs), spatial and temporal harmonic balance procedures are conducted simultaneously, which can be eciently achieved by the discrete sine transform and the fast Fourier transform. An additional coordinate associated with the generalized coordinates of the trial functions for the spatial discretization is introduced to make the solution satisfy all boundary conditions, and a relationship of the additional coordinate and the generalized coordinates is developed and used in the STHB method so that the test functions can be the same to the trial functions. Jacobian matrix of the harmonic balanced residual is obtained analyti- * the author's current institute is Georgia Institute of Technology, Atlanta, Georgia, 30332 cally, which can be used in Newton method for solving the periodic response. The STHB method and Jacobian matrix make the calculation of the periodic solution for the nonlinear string with a linear spring boundary condition ecient and easy to be implemented by computer programs. The relationship between the Jacobian matrix and the system matrix of the linearized ODEs are developed, so that one can directly obtain the Toeplitz form of the system matrix, and Hill's method can be used to analyze the stability with the eigenvalues of the Toeplitz-form system matrix without the derivation of the ODEs. The frequency curve of the periodic solutions is obtained and their stability is indicated by the method in this work.