We have studied the effect of impurity doping on the optical properties of indium phosphide (InP) nanowires. Photoluminescence measurements have been performed on individual nanowires at low temperatures (5¿70 K) and at low excitation intensities (0.5¿10 W/cm2). We show that the observed redshift (200 meV) and the linewidth (70 meV) of the emission of p-type InP wires are a result of a built-in electric field in the nanowires. This bandbending is induced by Fermi-level pinning at the nanowire surface. Upon increasing the excitation intensity, the typical emission from these p-InP wires blueshifts with 70 meV/decade, due to a reduction of the bandbending induced by an increase in the carrier concentration. For intrinsic and n-type nanowires, we found several impurity-related emission lines.