We present a simple and green approach for synthesis of gold nanoparticles (AuNps) using analgesic drug diflunisal (DF) as capping and stabilizing agent in aqueous solution. Characterization of the synthesized diflunisal-derived gold nanoparticles (DF-AuNps) was performed by ultraviolet–visible (UV–Vis) spectroscopy, revealing the surface plasmon absorption band at 520 nm under optimized experimental conditions. Fourier-transform infrared (FTIR) spectroscopy established the effective interaction of the capping agent with the AuNps. Topographical features of the synthesized DF-AuNps were assessed by atomic force microscopy (AFM), revealing average particle height of 29 nm to 32 nm. X-ray diffractometry was used to study the crystalline nature, revealing that the synthesized DF-AuNps possessed excellent crystalline properties. The synthesized DF-AuNps were employed to modify the surface of glassy carbon electrode (GCE) for selective determination of piroxicam (PX) using differential pulse voltammetry technique. The fabricated Nafion/DF-AuNps/GCE sensor exhibited high sensitivity compared with bare GCE. The current response of the fabricated sensor was found to be linear in the PX concentration range of 0.5 μM to 50 μM, with limit of detection (LOD) and limit of quantification (LOQ) of 50 nM and 150 nM, respectively. The proposed sensor was successfully utilized for sensitive and rapid determination of PX in human serum, urine, and pharmaceutical samples.