Terahertz-frequency optical pulses can resonantly drive selected vibrational modes in solids and deform their crystal structures. In complex oxides, this method has been used to melt electronic order, drive insulator-to-metal transitions and induce superconductivity. Strikingly, coherent interlayer transport strongly reminiscent of superconductivity can be transiently induced up to room temperature (300 kelvin) in YBa2Cu3O6+x (refs 9, 10). Here we report the crystal structure of this exotic non-equilibrium state, determined by femtosecond X-ray diffraction and ab initio density functional theory calculations. We find that nonlinear lattice excitation in normal-state YBa2Cu3O6+x at above the transition temperature of 52 kelvin causes a simultaneous increase and decrease in the Cu-O2 intra-bilayer and, respectively, inter-bilayer distances, accompanied by anisotropic changes in the in-plane O-Cu-O bond buckling. Density functional theory calculations indicate that these motions cause drastic changes in the electronic structure. Among these, the enhancement in the character of the in-plane electronic structure is likely to favour superconductivity.