Studies of exotic hadrons such as the χc1(3872) state provide crucial insights into the fundamental force governing the strong interaction dynamics, with an emerging frontier to investigate their production in high energy collisions where a partonic medium is present. The latest experimental measurements from the Large Hadron Collider show an intriguing evolution pattern of the χc1(3872)-to-ψ(2S) yield ratio from proton-proton collisions with increasing multiplicities toward proton-lead and lead-lead collisions. Here we propose a mechanism of medium-assisted enhancement for the χc1(3872) production, which competes with the more conventional absorption-induced suppression and results in a nonmonotonic trend from small to large colliding systems. Realistic simulations from this model offer a quantitative description of all available data. Predictions are made for the centrality dependence of this observable in PbPb collisions as well as for its system-size dependence from OO and ArAr to XeXe and PbPb collisions. In both cases, a nonmonotonic behavior emerges as the imprint of the competition between enhancement and suppression and can be readily tested by future data. Published by the American Physical Society 2024