Thermally stable mesoporous hexagonal aluminophosphates (UHM-1) and silicoaluminophosphates (UHM-3) are synthesized based on ion-pair interactions of aluminophosphate species in the presence of tetramethylammonium hydroxide with a cationic surfactant [C16H33NMe3Cl].