A novel magnetic sorbent was introduced involving a zinc–nickel ferrite@nickel–aluminum layered double hydroxide (Zn-NiFe2O4@Ni-Al LDH) nanocomposite. The Zn-NiFe2O4@Ni–Al LDH was synthesized through a co-precipitation method, and characterized using several techniques. The nanocomposite was shown to be an efficient sorbent for the pre-concentration of mefenamic acid prior to its detection by differential pulse voltammetry using a glassy carbon electrode modified with carbon nanotubes. To achieve the best extraction efficiency, the effects of various parameters such as pH, the sorbent dosage, extraction time, elution conditions, and sample volume were studied and optimized. Under the optimized experimental conditions, the calibration plot was linear in two concentration ranges from 50 to 100 nM (R2 = 0.9944) and 100–700 nM (R2 = 0.9913). The limit of detection was calculated to be 6.3 nM, and the precision of the method in the terms of intra-day and inter-day relative standard deviations (n = 5; mefenamic acid concentration = 100 nM) were 1.4% and 2.4%, respectively. The accuracy of the method was assessed by analyzing a pharmaceutical dosage form of the analyte, and comparing the results with those obtained from a standard method. To evaluate the applicability of the method, it was applied for trace determination of mefenamic acid in tablet, human plasma, urine, and pharmaceutical wastewater samples, and the satisfactory relative recovery values (96.0–103.1%) were attained for the spiked samples. The easy separation from the solution by applying an external magnet, high surface area, high stability in the strong alkaline solutions, and high reusability (more than 60 adsorption/desorption cycles) are some advantages of the synthesized nanosorbent.