After TiO2 nanoparticles were surface modified by the coupling agent anilinomethyltriethoxysilane (AMTES-TiO2), polyaniline (PANT) was grafted onto the surface of the AMTES-TiO2 nanoparticles by in situ chemically oxidative polymerization resulting in a PANI/AMTES-TiO2 nanocomposite photocatalyst. PANI and TiO2 are linkaged by chemical bonds. The nanocomposites were characterized using Fourier transform infrared spectroscopy (FTIR), thermogravimetric analysis (TGA), X-ray diffraction (XRD), UV-Visible diffuse reflectance spectrum (UV-Vis-DRS) and photoluminescence (PL). The photocatalytic activity was evaluated by the degradation of methylene blue (MB) in aqueous solution under UV and solar Light irradiation. Results show that the sensitizing effect of PANI can improve the light response of TiO2 and enhance the separation efficiency of electron and hole pairs which in turn promotes the photocatalytic ability of the nanocomposites. The mass ratio (w) of aniline to AMTES-TiO2 has a significant effect on the photocatalytic activity of nanocomposites and the optimal activity is obtained when the w is 0.025.