We investigate the effect of the nature of the substrate and the bottom interface on the out-of-plane polarization orientation of ultrathin (10-nm) lead zirconate titanate (PZT) thin films of (001) orientation by photoelectron spectroscopy of samples without surface contamination. The substrate nature is varied between insulator (strontium titanate, STO) and semiconductor (Nb-doped STO, STON) and finally to a metal with a work function lower than that of PZT (strontium ruthenate, SRO). Outward polarization is obtained for PZT/STON(001) and inward polarization is obtained for PZT/STO(001) and PZT/SRO(001). Explanations are given for all these typical cases, the main elements being charge accumulation for compensation of the depolarization field, self-doping of PZT films, and the interface electric field driving the orientation of the polarization of the ferroelectric films. We find p-type self-doping is correlated with the inward polarization, and the driving field is formed between a negatively charged region with negatively ionized acceptors near the interface with the substrate and the p-type degenerate region with holes accumulated inside, toward the surface. This mechanism may be reversed under the assumption of n-type self-doping, positively ionized donors near the interface, and accumulated electrons toward the surface in the case of an interface with a substrate with a higher work function, being in line with recent data (PZT/Pt or BaTiO3/SRO).