Despite their inherent non-equilibrium nature1, living systems can self-organize in highly ordered collective states2,3 that share striking similarities with the thermodynamic equilibrium phases4,5 of conventional condensed matter and fluid systems. Examples range from the liquid-crystal-like arrangements of bacterial colonies6,7, microbial suspensions8,9 and tissues10 to the coherent macro-scale dynamics in schools of fish11 and flocks of birds12. Yet, the generic mathematical principles that govern the emergence of structure in such artificial13 and biological6-9,14 systems are elusive. It is not clear when, or even whether, well-established theoretical concepts describing universal thermostatistics of equilibrium systems can capture and classify ordered states of living matter. Here, we connect these two previously disparate regimes: Through microfluidic experiments and mathematical modelling, we demonstrate that lattices of hydrodynamically coupled bacterial vortices can spontaneously organize into distinct phases of ferro- and antiferromagnetic order. The preferred phase can be controlled by tuning the vortex coupling through changes of the inter-cavity gap widths. The emergence of opposing order regimes is tightly linked to the existence of geometry-induced edge currents15,16, reminiscent of those in quantum systems17-19. Our experimental observations can be rationalized in terms of a generic lattice field theory, suggesting that bacterial spin networks belong to the same universality class as a wide range of equilibrium systems.