In this work, an electrochemical sensor constructed using a carbon paste electrode (CPE), modified with mesoporous silica encapsulating polyaniline (PANI) decorated with gold nanoparticles (GNPs) for the detection of ascorbic acid (AA), was presented. First of all, PANI latex was synthesized by emulsion polymerization. Then, the acid-catalyzed sol–gel solutions of tetraethyl silicate (TEOS) was prepared in the presence of d-glucose, followed by encapsulation of previously prepared PANI latex into as-prepared sol-gel solution. Upon formation of silica frameworks, electroactive composite powder was obtained. Subsequently, the as-prepared composite powder was subjected to Soxhlet extraction to remove d-glucose and the final product was denoted as PM silica. On the other hand, PGM silica was obtained by immersing PM silica in 5mL of 0.10mM HAuCl4 solution for 6h, which reduced the gold nanoparticles (GNPs) onto the surface of PANI chains located inside the nanochannels of wormhole-like mesoporous silica framework. The redox reactions that mediated between EB form of PANI and aqueous HAuCl4 solution were monitored and confirmed by FTIR spectra. The appearance of GNPs inside the PGM silica was characterized by TEM, XPS, XRD, and BET analyses. PGM silica was found to reveal higher redox capability as compared to that of PM silica based on the electrochemical CV studies.It should be noted that PGM silica-modified CPE was found to exhibit high sensitivity, a relatively low limit of detection, excellent sensing repeatability and a broader linear dynamic range for AA detection than those of bare CPE or PM silica-modified CPE. Moreover, A electrochemical sensor constructed from PGM silica-modified CPE was found to reveal better selectivity for a tertiary mixture of AA/DA/UA as compared to that of PM silica-modified CPE based on a series of studies of differential pulse voltammograms. In this work, the fabricated sensor showed reliable data in detecting AA in the tested commercially available products.