nanostructured magnetic materials are important for many advanced applications. Consequently, new methods for their fabrication are critical. However, coupling self-assembly to the generation of magnetic materials in a simple, straight-forward manner has remained elusive. Although several approaches have been considered, most have multiple processing steps, thus diminishing their use of self-assembly to influence magnetic properties. Here we develop novel block copolymers that are preprogrammed with the necessary chemical information to microphase separate and deliver room temperature ferromagnetic properties following a simple heat treatment. The importance of the nanostructured confinement is demonstrated by comparison with the parent homopolymer, which provides only paramagnetic materials, even though it is chemically identical and has a higher loading of the magnetic precursor. In addition to the room temperature ferromagnetic properties originating from the block copolymer, the in situ generation densely functionalizes the surface of the magnetic elements, rendering them oxidatively stable.