Acyclovir (ACV), a synthetic nucleoside derivative of purine, is one of the most potent antiviral medications recommended in the specific management of varicella-zoster and herpes simplex viruses. The molecularly imprinted polymer (MIP) was utilized to create an effective and specific electrochemical sensor using a straightforward photopolymerization process to determine ACV. The polymeric thin coating was developed using the template molecule ACV, a functional monomer acrylamide, a basic monomer 2-hydroxyethyl methacrylate, a cross-linker ethylene glycol dimethacrylate, and a photoinitiator 2-hydroxy-2-methyl propiophenone on the exterior of the glassy carbon electrode (GCE). Scanning electron microscopy, attenuated total reflectance−Fourier transform infrared spectroscopy, electrochemical impedance spectroscopy, and cyclic voltammetry were employed for the purpose of characterizing the constructed sensor (AM-ACV@MIP/GCE). Differential pulse voltammetry and a 5 mM ferrocyanide/ferricyanide ([Fe(CN) 6 ] 3−/4− ) redox reagent were used to detect the ACV binding to the specific cavities on MIP. The study involves density functional theory (DFT) calculations, which were conducted to investigate template-functional monomer interactions thoroughly, calculate template-functional monomer interaction energies, and determine the optimal template/functional monomer ratio. DFT calculations were performed using Becke's three-parameter hybrid functional with the Lee−Yang−Parr correlation functional (B3LYP) method and 6-31G(d,p) basis set. The sensor exhibits linear performance throughout the concentration region 1 × 10 −11 to 1 × 10 −10 M, and the limit of detection and limit of quantification were 7.15 × 10 −13 M and 2.38 × 10 −12 M, respectively. For the electrochemical study of ACV, the sensor demonstrated high accuracy, precision, robustness, and a short detection time. Furthermore, the developed electrochemical sensor exhibited exceptional recovery in tablet dosage form and commercial human blood samples, with recoveries of 99.40 and 100.44%, respectively. The findings showed that the AM-ACV@MIP/GCE sensor would effectively be used to directly assess pharmaceuticals from actual specimens and would particularly detect ACV compared to structurally similar pharmaceutical compounds.