Cells migrating through complex three-dimensional environments experience considerable physical challenges, including tensile stress and compression. To move, cells need to resist these forces while also squeezing the large nucleus through confined spaces. This requires highly coordinated cortical contractility. Microtubules can both resist compressive forces and sequester key actomyosin regulators to ensure appropriate activation of contractile forces. Yet, how these two roles are integrated to achieve nuclear transmigration in three dimensions is largely unknown. Here, we demonstrate that compression triggers reinforcement of a dedicated microtubule structure at the rear of the nucleus by the mechanoresponsive recruitment of cytoplasmic linker-associated proteins, which dynamically strengthens and repairs the lattice. These reinforced microtubules form the mechanostat: an adaptive feedback mechanism that allows the cell to both withstand compressive force and spatiotemporally organize contractility signalling pathways. The microtubule mechanostat facilitates nuclear positioning and coordinates force production to enable the cell to pass through constrictions. Disruption of the mechanostat imbalances cortical contractility, stalling migration and ultimately resulting in catastrophic cell rupture. Our findings reveal a role for microtubules as cellular sensors that detect and respond to compressive forces, enabling movement and ensuring survival in mechanically demanding environments.