An end-tethered polymer chain compressed between two pistons undergoes an abrupt transition from a confined coil state to an inhomogeneous flowerlike conformation partially escaped from the gap. This phase transition is first order in the thermodynamic limit of infinitely long chains. A rigorous analytical theory is presented for a Gaussian chain in two ensembles: ͑a͒ the H-ensemble, in which the distance H between the pistons plays the role of the independent control parameter, and ͑b͒ the conjugate f-ensemble, in which the external compression force f is the independent parameter. Details about the metastable chain configurations are analyzed by introducing the Landau free energy as a function of the chain stretching order parameter. The binodal and spinodal lines, as well as the barrier heights between the stable and metastable states in the free energy landscape, are presented in both ensembles. In the loop region for the average force with dependence on the distance H ͑i.e., in the H-ensemble͒ a negative compressibility exists, whereas in the f-ensemble the average distance as a function of the force is strictly monotonic. The average fraction of imprisoned segments and the lateral force, taken as functions of the distance H or the average H, respectively, have different behaviors in the two ensembles. These results demonstrate a clear counterexample of a main principle of statistical mechanics, stating that all ensembles are equivalent in the thermodynamic limit. The authors show that the negative compressibility in the escape transition is a purely equilibrium result and analyze in detail the origin of the nonequivalence of the ensembles. It is argued that it should be possible to employ the escape transition and its anomalous behavior in macroscopically homogeneous, but microscopically inhomogeneous, materials.