This study is the first to use a new ZSM-5 zeolite-based composite decorated with iron oxide magnetic nanoparticles and modified with hexadecyltrimethylammonium bromide surfactant (i.e., HDTMA-ZSM-5/Fe2O3) as an efficient sorbent for magnetic dispersive solid-phase extraction (MDSPE) of nonsteroidal anti-inflammatory drugs in water and urine samples with subsequent measurement by liquid chromatography diode array detection. Experimental factors affecting MDSPE were optimized using a multivariate optimization strategy. The optimum experimental conditions were: amount of sorbent, 40 mg; sample pH, 2.2; NaCl concentration, 2.5%; extraction time, 2 min; eluent solvent, methanol; eluent solvent volume, 424 μL; and elution time, 2 min. The linearity of the method was studied from 3.3 to 400 µg L-1 (N=8) for ketoprofen, from 1.7 to 400 µg L-1 (N=8) for felbinac, from 6.6 to 400 µg L-1