We extend the definition of the classical Jacobi polynomials with indexes $\af,\bt>-1$ to allow $\af$ and/or $\beta$ to be negative integers. We show that the generalized Jacobi polynomials, with indexes corresponding to the number of boundary conditions in a given partial differential equation, are the natural basis functions for the spectral approximation of this partial differential equation. Moreover, the use of generalized Jacobi polynomials leads to much simplified analysis, more precise error estimates and well conditioned algorithms.