In this work, an in situ acylation combined with solid-phase microextraction coupled to gas chromatography and mass spectrometry method has been developed for simultaneously determining haloanisoles (2,4,6-trichloranisole, 2,4,6-tribromoanisole), and their direct precursors (2,4,6-trichlorophenol, 2,4,6-tribromophenol) and indirect precursors (2-chloropenol, 2,4-dichlorophenol, 2-bromophenol, 2,4-dibromophenol) in water. The key parameters for the solid-phase microextraction were determined by using Plackett-Burman screening and optimized by central composite optimization. Under optimal conditions, the eight compounds can be analyzed in a short time (33 min) with a strong linearity ranging from 2 to 200 ng/L (correlation coefficient greater than 0.996), showing good sensitivities with the limit of detection in a range of 0.23-0.91 ng/L and a limit of quantification of 0.77-3.03 ng/L, good repeatability (2.00-9.10%) and interday precision (1.67-11.3%). When environmental water samples were treated, the recoveries of target compounds were 75.5-127.3%, suggesting that the developed method could be applied in probing the origin of haloanisoles and monitoring halophenols and haloanisoles in natural waters at concentration levels of ng/L.