We used the exquisite sensitivity and resolution of the ALMA interferometer to capture the polarized emission of dust in the circumstellar material around a young protostar, B335. We could map the polarized emission from a radius of 50 AU up to 1000 AU (astronomical unit = Earth-Sun distance = 150 million kilometers), showing that this young star in formation undergoes the effect of the field over a very large area. We have shown that the magnetic field structure in B335 has a strikingly ordered topology in the core, with a transition from a large-scale poloidal magnetic field, in the outflow direction, to strongly pinched in the equatorial direction. We carried out a comparison with predictions of hydrodynamical collapse and have shown that only models where the magnetic field is dynamically relevant could reproduce our observations.