We perform full-magnetohydrodynamics simulations on various initially helical configurations and show that they reconfigure into a state where the magnetic field lines span nested toroidal surfaces. This relaxed configuration is not a Taylor state, as is often assumed for relaxing plasma, but a state where the Lorentz force is balanced by the hydrostatic pressure, which is lowest on the central ring of the nested tori. Furthermore, the structure is characterized by a spatially slowly varying rotational transform, which leads to the formation of a few magnetic islands at rational surfaces. We then obtain analytic expressions that approximate the global structure of the quasistable linked and knotted plasma configurations that emerge, using m...