We investigate electronic and magnetic properties of carbon nanotubes interacting with Fe atoms through first-principles theoretical calculations. For a single Fe atom on the tube surface, due to the curvature effect, there exists a difference in effective coordination number between inside and outside of the nanotube, and a complete promotion of 4s electrons into 3d orbitals occurs inside the nanotube. When Fe atoms are encapsulated in the form of nanowires inside the nanotube, their magnetic properties strongly depend on wire thickness. For thin nanowires with very weak interactions between Fe and C atoms, magnetic moments are similar to those for their free-standing nanowires, and electron conduction mostly occurs through the wires well protected from oxidation. On the other hand, the magnetic moments of thicker nanowires are greatly reduced. (c) 2005 Elsevier B.V. All rights reserved.