The issue of water resource pollution resulting from the discharge of dyes is a matter of great concern for the environment. In this investigation, a new ternary heterogeneous Mg−Al LDH@g-C 3 N 4 X@Ag 3 PO 4 Y (X = wt % of g-C 3 N 4 with respect to Mg−Al layered double hydroxide (LDH) and Y = wt % of Ag 3 PO 4 loaded on Mg−Al LDH@g-C 3 N 4 30) nanocomposite was prepared with the aim of increasing charge carrier separation and enhancement of photocatalytic performance to degrade methylene blue (MB) dye. The prepared samples were subjected to characterization via Fourier-transform infrared spectroscopy, field emission scanning electron microscopy, energy-dispersive Xray, transmission electron microscopy, X-ray diffraction, UV−vis diffuse reflectance spectroscopy, photoluminescence, and photoelectrochemical analysis. It was observed that in the presence of the composite of Mg−Al LDH and g-C 3 N 4 , the photocatalytic decomposition of MB under 150 W mercury lamp illumination increases significantly as opposed to Mg−Al LDH alone, and the Mg−Al LDH@g-C 3 N 4 level with Ag 3 PO 4 coating causes the complete degradation of MB to occur in less time. The outcomes show that the Mg−Al LDH@g-C 3 N 4 30@Ag 3 PO 4 5 nanocomposite demonstrated the highest photodegradation activity (99%). Scavenger tests showed that the two most effective agents in the photodegradation of MB are holes and hydroxyl radicals, respectively. Finally, a type II heterojunction photocatalytic degradation mechanism for MB by Mg−Al LDH@g-C 3 N 4 30@Ag 3 PO 4 5 was proposed.