next-generation electronic, photonic or spintronic devices will be based on nanoscale functional units, such as quantum dots, isolated spin centres or single-molecule magnets. The key challenge is the coupling of the nanoscale units to the macroscopic world, which is essential for read and write purposes. Carbon nanotubes with one macroscopic and two nanoscopic dimensions provide an excellent means to achieve this coupling. Although the dimensions of nanotube internal cavities are suitable for hosting a wide range of different molecules, to our knowledge, no examples of molecular magnets inserted in nanotubes have been reported to date. Here we report the successful encapsulation of single-molecule magnets in carbon nanotubes, yielding a new type of hybrid nanostructure that combines all the key single-molecule magnet properties of the guest molecules with the functional properties of the host nanotube. The findings may pave the way to the construction of spintronic or ultrahigh-density magnetic data storage devices.