Abstract We introduce a duality between two-dimensional XY-spin models with symmetry-breaking perturbations and certain four-dimensional SU(2) and SU(2)/ $ {\mathbb{Z}_2} $ gauge theories, compactified on a small spatial circle $ {\mathbb{R}^{{^{{{1},{2}}}}}} $ × $ {\mathbb{S}^{{^{{1}}}}} $ , and considered at temperatures near the deconfinement transition. In a Euclidean set up, the theory is defined on $ {\mathbb{R}^{{^{{2}}}}} $ × $ {\mathbb{T}^{{^{{2}}}}} $ . Similarly, thermal gauge theories of higher rank are dual to new families of “affine” XY-spin models with perturbations. For rank two, these are related to models used to describe the melting of a 2d crystal with a triangular lattice. The connection is made through a multi-component electric-magnetic Coulomb gas representation for both systems. Perturbations in the spin system map to topological defects in the gauge theory, such as monopole-instantons or magnetic bions, and the vortices in the spin system map to the electrically charged W-bosons in field theory (or vice versa, depending on the duality frame). The duality permits one to use the two-dimensional technology of spin systems to study the thermal deconfinement and discrete chiral transitions in four-dimensional SU(N c ) gauge theories with n f ≥1 adjoint Weyl fermions.