Sulfamethoxazole (SMX), a widely used antibiotic, poses significant environmental and health risks due to its persistence and mobility in water systems, potentially leading to antibiotic resistance and ecological harm. Herein, we developed an electrochemical sensor based on Bismuth Ferrite (BiFeO3)/Halloysite Nanotube (BFO/HNT) composite for sensitive and selective SMX detection. The BFO/HNT composite was synthesized via a hydrothermal method and comprehensively characterized using EDS mapping, HRTEM, XRD, FT-IR, and XPS analysis. The BFO/HNT composite enhances the sensor’s performance due to its unique properties, such as increased electrochemical surface area (ECSA) and efficient electron transfer capability. The B-cation (Fe) in the BiFeO3 matrix plays a crucial role in boosting the electrochemical response by facilitating redox reactions. In addition, the HNTs provide a high surface area and excellent adsorption capabilities, which improve the sensor’s sensitivity by facilitating better interaction with SMX molecules. As the results, the prepared sensor demonstrates an impressive linear detection range of 0.01 to 2 µM and 22 to 122 µM, with a detection limit as low as 0.017 µM. Practical applications were validated by detecting SMX in tap water and artificial saliva, achieving high recovery rates of 98.87 % and 99.11 %.