  Nonvolatile optical manipulation of material properties on demand is a highly
sought-after feature in the advancement of future optoelectronic applications.
While the discovery of such metastable transition in various materials holds
good promise for achieving this goal, their practical implementation is still
in the nascent stage. Here, we unravel the nature of the ultrafast
laser-induced hidden state in 1T-TaS2 by systematically characterizing the
electronic structure evolution throughout the reversible transition cycle. We
identify it as a mixed-stacking state involving two similarly low-energy
interlayer orders, which is manifested as the charge density wave phase
disruption. Furthermore, our comparative experiments utilizing the single-pulse
writing, pulse-train erasing and pulse-pair control explicitly reveal the
distinct mechanism of the bidirectional transformations -- the ultrafast
formation of the hidden state is initiated by a coherent phonon which triggers
a competition of interlayer stacking orders, while its recovery to the initial
state is governed by the progressive domain coarsening. Our work highlights the
deterministic role of the competing interlayer orders in the nonvolatile phase
transition in the layered material 1T-TaS2, and promises the coherent control
of the phase transition and switching speed. More importantly, these results
establish all-optical engineering of stacking orders in low-dimensional
materials as a viable strategy for achieving desirable nonvolatile electronic
devices.
