Electrically driven semiconductor lasers are used in technologies ranging from telecommunications and information storage to medical diagnostics and therapeutics. The success of this class of lasers is due in part to well-developed planar semiconductor growth and processing, which enables reproducible fabrication of integrated, electrically driven devices. Yet this approach to device fabrication is also costly and difficult to integrate directly with other technologies such as silicon microelectronics. To overcome these issues for future applications, there has been considerable interest in using organic molecules, polymers, and inorganic nanostructures for lasers, because these materials can be fashioned into devices by chemical processing. Indeed, amplified stimulated emission and lasing have been reported for optically pumped organic systems and, more recently, inorganic nanocrystals and nanowires. However, electrically driven lasing, which is required in most applications, has met with several difficulties in organic systems, and has not been addressed for assembled nanocrystals or nanowires. Here we investigate the feasibility of achieving electrically driven lasing from individual nanowires. Optical and electrical measurements made on single-crystal cadmium sulphide nanowires show that these structures can function as Fabry-Perot optical cavities with mode spacing inversely related to the nanowire length. Investigations of optical and electrical pumping further indicate a threshold for lasing as characterized by optical modes with instrument-limited linewidths. Electrically driven nanowire lasers, which might be assembled in arrays capable of emitting a wide range of colours, could improve existing applications and suggest new opportunities.