NiO p-type semiconducting nanowires with high aspect ratios up to approximately 2000 have been prepared by chemical reduction under assistance of magnetic fields and subsequent heat treatment method. The diameter of NiO nanowires is about 150 nm and the length can be up to 300 μm. Ni nanowires have been prepared from a structure of Ni nanospheres at atmospheric pressure. Transformation from Ni nanowires to NiO semiconducting nanowires via in situ chemical oxidation process in open air have been conducted by undergoing a process of an amorphous oxidation. Heat treatment results in significant influence on the grain size in the NiO nanowire structure. NiO nanowires with crystalline grain size of about 12 nm is characteristic with a band gap energy of about 4.20 eV, which is larger than the bulk NiO material (3.65 eV). Meanwhile, we find that the optical band gap energy gradually increases with the decrease of the crystalline grain size. NiO nanowires with different grain sizes have been used to fabricate arrays for a gas sensor under an external magnetic field. NH3 gas sensing capability at room temperature by NiO nanowire arrays is characteristic for its high sensitivity, fast response, rapid recovery and good reproducibility.