Herein, we report a green and an effective strategy for the synthesis of polyaniline-silver chloride (AgCl@PANI) nanocomposites by using facile in-situ chemical oxidative polymerization method in the presence of as-synthesized silver nanoparticles (Ag NPs) for the study of their photocatalytic activity towards the photodegradation of methylene blue (MB) under UV irradiation. The contents of Ag NPs varied from 2% to 6% during polymerization reaction to get AgCl@PANI nanocomposites. These synthesized polymer nanocomposites were characterized for their structural and optical properties, thermal stability, dc conductivity and photocatalytic activity by FT-IR spectroscopy, XRD, UV–Vis spectroscopy, TGA, SEM, standard four probe method and the photodegradation activity of MB, respectively. XRD analysis confirm the successful formation of AgCl@PANI nanocomposites without the presence of additional phases. TGA shows that AgCl@PANI nanocomposites have excellent thermal stability due to the barrier effect of AgCl moieties bounded with in the polymer chain and the strong physiochemical interactions between PANI and AgCl as inferred from FT-IR and UV–vis analysis. Under UV irradiation, the AgCl@PANI nanocomposite, with 4 wt% of Ag NPs (AgCl@PANI-4%), demonstrated excellent photocatalytic activity for MB degradation with the photodegradation percentage of ∼ 99 % in 20 min. The experimental findings illustrate that the superior photocatalytic activity of AgCl@PANI nanocomposites is owing to incorporation of AgCl moieties in the polymer structure, less needed energy for the formation of electron-hole pairs in the quinoid ring of PANI in the UV-region, enhanced light absorption owing to smaller grain size morphology, high surface area of the nanocomposite and high electrical conductivity (128 mS.cm−2). These results suggest the potential of these synthesized conjugated polymer-based nanocomposites as a photocatalyst for cost-effective and efficient wastewater treatment for the industrial applications.