Abstract The present research presents synthesis and substantial utilization of a nanocomposite of boron nitride-Fe3O4–Pd (BN–Fe3O4–Pd) for modifying carbon paste electrode (CPE) to determine sulfamethoxazole (SMZ). Various techniques such as transmission electron microscopy, energy-dispersive X-ray spectroscopy, and X-ray photoelectron spectroscopy were applied to characterize the synthesized nanocomposite. In addition, differential pulse voltammetry (DPV) was employed for anodic peak and quantitatively detecting SMZ. Based on the optimized condition, this novel sensor exhibited a linear response of 0.02–420.0 μM. The limitation of detection and quantitation values for SMZ were determined to be 0.008 μM and 0.027 μM, respectively. Moreover, this electrode could substantially be applied for the analysis of SMZ in the real samples (e.g., urine, tap water, river water).