Given the availability of a wide range of properties not possessed by individual materials, nanocomposites based on conducting polymers and inorganic materials have attracted much deserved attention. However, there has been little attempt to optimize the synthesis and thermal properties of polyaniline–clay nanocomposites. In this study, the synthesis and thermal properties of polyaniline (PANi) and polyaniline–clay nanocomposites (PACN) were performed by systematically varying the feed composition. Both PANi and polyaniline–montmorillonite (MMT) nanocomposites were prepared by using ammonium persulfate (APS) as the oxidant. The chemical structure of the nanocomposites was studied by Fourier transform infrared spectroscopy (FTIR). FTIR spectra confirmed the presence of clay in the nanocomposites and the existence of mainly the emiraldine form of PANi. Thermal analysis was performed by using thermogravimetric analysis (TGA) and differential scanning calorimetry (DSC). The morphology and structure of PANi and PACN were studied by scanning electron microscopy (SEM), wide-angle X-ray diffraction (WAXD), and transmission electron microscopy (TEM). Our results confirm the intercalation and partial exfoliation of clay. This study also showed that increasing the oxidant concentration resulted in decreasing thermal stability and melting temperature of PANi. The reinforcement of PANi with MMT resulted in increased thermal stability and increased melting point of PANi. It was also shown that the addition of only about 0.1 wt% of APS resulted in an optimal thermal stability and melting point for PANi.