We construct an anomaly-preserving compactification of 4d gauge theories, including SU (N ) Yang-Mills theory, N = 1 supersymmetric Yang-Mills theory, and QCD, down to 2d by turning on 't Hooft flux through T 2 . It provides a new framework to analytically calculate nonperturbative properties such as confinement, chiral symmetry breaking, and multi-branch structure of vacua. We give the semiclassical description of these phenomena based on the center vortex and show that it enjoys the same anomaly matching condition with the original 4d gauge theory. We conjecture that the weakcoupling vacuum structure on small T 2 × R 2 is adiabatically connected to the strongcoupling regime on R 4 without any phase transitions. In QCD with fundamental quarks as well, we can turn on 't Hooft flux either by activating SU (N f ) V symmetry twist for N f = N flavors or by introducing a magnetic flux of baryon number U (1) B for arbitrary N f flavors. In both cases, the weak-coupling center-vortex theory gives the prediction consistent with chiral Lagrangian of 4d QCD.