We present deep optical spectra of the archetypal young planetary nebula (PN) NGC 7027, covering a wavelength range from 3310 to 9160 Å. The observations were carried out by uniformly scanning a long slit across the entire nebular surface, thus yielding average optical spectra for the whole nebula. A total of 937 emission features are detected. The extensive line list presented here should prove valuable for future spectroscopic analyses of emission line nebulae. The optical data, together with the archival IUE and ISO spectra, are used to probe the temperature and density structures and to determine the elemental abundances from lines produced by different excitation mechanisms. Electron temperatures have been derived from the hydrogen recombination Balmer jump (BJ), from ratios of He I optical recombination lines (ORLs) and from a variety of diagnostic ratios of collisionally excited lines (CELs). Electron densities have been determined from the intensities of high-order H I Balmer lines and of He II Pfund lines, as well as from a host of CEL diagnostic ratios. CEL and ORL diagnostics are found to yield compatible results. Adopting respectively electron temperatures of Te = 12 600 and 15 500 K for ions with ionization potentials lower or higher than 50 eV and a constant density of N_e=47 000 cm-3, elemental abundances have been determined from a large number of CELs and ORLs. The C2+/H^+, N2+/H^+, O2+/H+ and Ne2+/H+ ionic abundance ratios derived from ORLs are found to be only slightly higher than the corresponding CEL values. We conclude that whatever mechanism is causing the BJ/CEL temperature discrepanies and the ORL/CEL abundance discrepancies that have been observed in many PNe, it has an insignificant effect on this bright young compact PN. The properties of the central star are also discussed. Based on the integrated spectrum and using the energy-balance method, we have derived an effective temperature of 219 000 K for the ionizing star. Finally, we report the first detection in the spectrum of this bright young PN of Raman-scattered O VI features at 6830 and 7088 Å, pointing to the existence of abundant neutral hydrogen around the ionized regions.