We report ab initio calculations of magnetic and spin-polarized quantum transport properties of pure and nitrogen-doped carbon atomic wires. For finite-sized wires with even number of carbon atoms, total magnetic moment of 2 B is found. On the other hand, wires with odd number atoms have no net magnetic moment. Doped with one or two nitrogen atom͑s͒, the carbon atomic wires exhibit a spin-density-wave-like state. The magnetic properties can be rationalized through bonding patterns and unpaired states. When the wire is sandwiched between Au electrodes to form a transport junction, perfect spin filtering effect can be induced by slightly straining the wire.Due to the remarkably long spin coherence time, magnetism, and quantum transport in carbon nanostructures have attracted considerable attention for possible applications in spintronics. 1 Spin polarization in carbon structures may come from proximity to ferromagnetic metal 2,3 or from doped transition metal atoms such as Fe, Cr, or V, Carbon-based systems such as exdohedral or endohedral fullerenes ͓C 60 N ͑Ref. 7͒ and N@C 60 ͑Ref. 8͒, etc.͔ were also found to have local magnetic moments and these fullerene systems are considered useful for quantum information technology. 8 Very interestingly, even pure carbon structure is predicted to have magnetism such as that occurring along the zigzag edges 9,10 of graphene nanoribbons, or near vacancies 11 in graphene. The theoretical prediction and successful experimental fabrication of single-layer graphene 12 have triggered substantial interests in exploiting magnetism in pure carbon systems. Magnetism found in materials containing only s and p electrons, instead of traditionally localized d or f electrons, should be extremely interesting to spintronics.Magnetism occurring in carbon nanostructures is usually rather localized, e.g., magnetic edge states along the boundary of zigzag graphene nanoribbons 9,10 or magnetic moments due to dangling bonds and vacancies. 11 In general, the origin of magnetism in pure carbon nanostructures has not been understood to high satisfaction. In particular, when carbon nanostructures are contacted by nonmagnetic metal electrodes to form a transport device, an important question is how magnetic character of the carbon system is influenced by the electrodes. This issue is of fundamental importance if magnetism in pure carbon nanostructure is to be exploited for spintronics application. It is the purpose of this paper to report our investigation on this issue.To be specific, we focus on magnetism and spin-polarized quantum transport in carbon atomic wires which are important for molecular-scale electronics due to their stable and extremely thin structures. 5,6,13-20 By using chemical techniques, linear carbon atomic wires containing up to 20 atoms has been synthesized experimentally. 21,22 A number of interesting charge transport properties have been predicted for carbon atomic wires sandwiched between two metal leads, including even-odd oscillatory conductance, 13 negative differential resi...