In this paper, we present a microscopic study of impurity resonance and tunneling magnetoresistance (TMR) for nanojunctions. We employ the Green's-function method to derive the tunneling wave functions and TMR from the spintronic model with nonmagnetic impurities and at a finite bias voltage. The analytical expressions for both direct and impurity-resonance tunnelings are obtained, where the lateral effect has been included. Within this framework, the TMR can be determined directly by the basic quantities of the junction, e.g., the position and the energy level of the impurity, the height and width of the barrier, the Fermi level and polarization of the electrodes, as well as the applied voltage. If the cross sectional area of the junction gets very small, we find that it is the impurity resonance and the quantum-coherence effect that control the bias dependence of TMR: the impurity resonance makes the TMR change from positive to negative, and the quantum-coherence effect decreases the TMR as the bias voltage increases. The experimental results of TMR for the junctions with the area smaller than $0.01\phantom{\rule{0.3em}{0ex}}\ensuremath{\mu}{\mathrm{m}}^{2}$ can then be explained naturally. We also find that the direct and impurity-resonance tunnelings will compete with each other when the area of the junction is enlarged. Taking into account both the contributions of direct tunneling and impurity-resonance tunneling, the total TMR agrees quite well with the more recent experiments on the larger-area nanojunctions.