A simple procedure has been developed and validated for the qualitative and quantitative analysis of several opiates (morphine, 6-acetylmorphine, codeine, 6-acetylcodeine) and tramadol in hair. The analytes were extracted from within the matrix via an overnight incubation with methanol at 65 degrees C, and afterwards the samples were cleaned up by mixed-mode solid-phase extraction. The extracts were derivatized with N-methyl-N-(trimethylsilyl) trifluoroacetamide with 5% trimethylchlorosilane and analyzed by gas chromatography-mass spectrometry in the selected ion monitoring mode. The method was linear from 0.05 (lower limit of quantitation) to 50 ng/mg (40 ng/mg for tramadol), with correlation coefficients higher than 0.99 for all compounds, accomplishing the cut-off values proposed by the Society of Hair Testing for the detection of these substances in hair (0.2 ng/mg). Intra- and interday precision and trueness were in conformity with the criteria normally accepted in bioanalytical method validation, and the sample cleanup step presented a mean efficiency higher than 90% for all analytes. Furthermore, using these incubation conditions, 6-acetylmorphine did not significantly hydrolyze to morphine. For these reasons, and because of its simplicity, the proposed method can be successfully applied in the determination of these compounds in hair samples, and is suitable for application in routine analysis with forensic purposes.