Using ab initio methods we successfully reproduce an unusual enhancement of magnetization experimentally observed in ferromagnetic SrRuO3 thin films deposited on the spin-triplet superconductor Sr2RuO4. We found that this enhancement is due to additional distortions of Sr2RuO4 induced by the film. These distortions - rotation of the RuO6 octahedra - lead to a gradual reconstruction of electronic structure of the substrate, such that the Fermi level turns out to be exactly at the peak of the local density of states, corresponding to the Ru ions close to the interface. This results in the magnetic instability. The distortions propagate deep into the substrate and favor the formation of magnetic moments on the Ru ions in Sr2RuO4 near the interface. Our estimates show that these distortions may penetrate into Sr2RuO4 substrate up to 40 nm in depth, which agrees with experimental observations.