We report on a direct measurement of electrical potential and field profiles across the n-i-p junction of hydrogenated nanocrystalline silicon (nc-Si:H) solar cells, using the nanometer-resolution potential imaging technique of scanning Kelvin probe force microscopy (SKPFM). It was observed that the electric field is nonuniform across the i layer. It is much higher in the p/i region than in the middle and the n/i region, illustrating that the i layer is actually slightly n-type. A measurement on a nc-Si:H cell with a higher oxygen impurity concentration shows that the nonuniformity of the electric field is much more pronounced than in samples having a lower O impurity, indicating that O is an electron donor in nc-Si:H materials. This nonuniform distribution of electric field implies a mixture of diffusion and drift of carrier transport in the nc-Si:H solar cells. The composition and structure of these nc-Si:H cells were further investigated by using secondary-ion mass spectrometry and Raman spectroscopy, respectively. The effects of impurity and structural properties on the electrical potential distribution and solar cell performance are discussed.