In this chapter we review recent advances in understanding the roles that magnetic fields play throughout the star formation process, gained through observations and simulations of molecular clouds, the dense, star-forming phase of the magnetised, turbulent interstellar medium (ISM). Recent results broadly support a picture in which the magnetic fields of molecular clouds transition from being gravitationally sub-critical and near equipartition with turbulence in low-density cloud envelopes, to being energetically sub-dominant in dense, gravitationally unstable star-forming cores. Magnetic fields appear to play an important role in the formation of cloud substructure by setting preferred directions for large-scale gas flows in molecular clouds, and can direct the accretion of material onto star-forming filaments and hubs. Low-mass star formation may proceed in environments close to magnetic criticality; high-mass star formation remains less well-understood, but may proceed in more supercritical environments. The interaction between magnetic fields and (proto)stellar feedback may be particularly important in setting star formation efficiency. We also review a range of widely-used techniques for quantifying the dynamic importance of magnetic fields, concluding that better-calibrated diagnostics are required in order to use the spectacular range of forthcoming observations and simulations to quantify our emerging understanding of how magnetic fields influence the outcome of the star formation process.