Microscopic study of the coexistence of structural distortion and superconductivity in high temperature superconductors