A series of new layered inorganic-organic nanocomposites, with organic functionalities directly bonded to an inorganic framework via the Si-C bond, were prepared by a template sol-gel synthesis. These layered Al- and Mg-silsesquioxanes were precipitated at room temperature by addition of aqueous base to an alcohol solution containing a mixture of AlCl3 or MgCl2 and a trialkoxysilane with a n-dodecyl, n-octyl, n-pentyl, 3-methacryloxypropyl, isobutyl, or phenyl functionality. The Si/Al and Si/Mg ratios of the reaction mixtures were 2:1 and 4:3, respectively, and were chosen to match the composition of clay mineral pyrophyllite (layered aluminosilicate) and talc (layered magnesiosilicate). X-ray diffraction and electron microscopy show that the products are crystalline with a layered structure. A comparison of basal spacings and length of the organic functionalities is consistent with a similar to 10 Angstrom inorganic layer and a bilayer arrangement of R groups for Al-silsesquioxanes and an interpenetrating arrangement of R groups for Mg-silsesquioxanes. FTIR and C-13 NMR spectra indicate that in the products the Si-C bond is intact and silanes are fully hydrolyzed, while the organic functionalities filling the interlayer space are in a solid-like environment. Si-29 NMR spectra reveal that silanes are not fully condensed and that the degree of condensation is higher in Mg-silsesquioxanes than Al-silsesquioxanes. Broad in-plane diffraction peaks and a variety of Al coordination states observed by Al-27 NMR are best explained by the defects in a clay-like inorganic framework caused by trifunctional Si. The most crystalline products were formed from long-chain alkyl-trialoxysilanes with Al, while trialkoxysilanes with shorter R groups gave less well-organized structures. This dependence on chain length suggests that the formation of the layered structure is due to self-assembly of the hydrolyzed trialkoxysilanes into lamellar micelles. The micelles act as a template for the formation of a clay-like inorganic framework by condensation between the silanols and aqueous metal species attracted by the negatively charged surfactant layers. Although the thermal stability of R group limits high-temperature applications, these materials may find use as sorbents, environmental barriers, polymer fillers, catalytic supports, or chemical sensors.