The evolution of the atomic structure of LaAlO3 grown on SrTiO3 was investigated using surface x-ray diffraction in conjunction with model-independent, phase-retrieval algorithms between two and five monolayers film thickness. A depolarizing buckling is observed between cation and oxygen positions in response to the electric field of polar LaAlO3, which decreases with increasing film thickness. We explain this in terms of competition between elastic strain energy, electrostatic energy, and electronic reconstructions. The findings are qualitatively reproduced by density-functional theory calculations. Significant cationic intermixing across the interface extends approximately three monolayers for all film thicknesses. The interfaces of films thinner than four monolayers therefore extend to the surface, which might affect conductivity.