We report a first-principles investigation of ultrathin BaTiO3 films with SrRuO3 electrodes. We find that the ionic relaxations in the metal-oxide electrode play a crucial role in stabilizing the ferroelectric phase. Comparison with frozen-phonon calculations shows that the degree of softness of the SrRuO3 lattice has an essential impact on the screening of ferroelectric polarization in BaTiO3. The critical thickness for ferroelectricity in BaTiO3 is found to be 1.2 nm. The results of our calculations provide a possible explanation for the beneficial impact of oxide electrodes on the switching and dielectric properties of ferroelectric capacitors.