We perform first-principles molecular dynamics of liquid oxygen in which the magnetic structure evolves according to a generalized density-functional scheme allowing for noncollinear spin configurations. We investigate both structural correlations between the orientations of the molecular axes and magnetic correlations between the orientations of the molecular magnetic moments, demonstrating a clear relation between the local molecular configuration and the relative magnetic arrangement. The nuclear structure factor obtained from the simulation is found to agree well with the experimental one. The calculated magnetic structure factor shows antiferromagnetic correlations between molecules in the first shell, in accord with spin-polarized neutron scattering measurements. We observe the formation of dynamically coupled molecules, known as O-4 units, in which the molecular moments are aligned in an antiferromagnetic fashion. An analysis based on the life time of such units, revealed that in most cases the O-4 units occur as transient configurations during collisions. However, we also observed a small fraction of O-4 units surviving for relatively long periods. To account for electronic excitations which are missed in our density-functional scheme, we complement our description with a mean field model for the thermal fluctuations of the magnetic structure. The combined scheme is found to improve the description of the magnetic neutron structure factor and allows us to study the dependence of the magnetic susceptibility on temperature.