Endohedral lanthanide ions packed inside carbon nanotubes (CNTs) in a one-dimensional assembly have been studied with a combination of high resolution transmission electron microscopy (HRTEM), scanning transmission X-ray microscopy (STXM), and X-ray magnetic circular dichroism (XMCD). By correlating HRTEM and STXM images we show that structures down to 30 nm are resolved with chemical contrast and record X-ray absorption spectra from endohedral lanthanide ions embedded in individual nanoscale CNT bundles. XMCD measurements of an Er$_3$N@C$_{80}$ bulk sample and a macroscopic assembly of filled CNTs indicates that the magnetic properties of the endohedral Er3+ ions are unchanged when encapsulated in CNTs. This study demonstrates the feasibility of local magnetic X-ray characterization of low concentrations of lanthanide ions embedded in molecular nanostructures.