A rapid and efficient one-pot method for the synthesis of quinazolinone derivatives and related heterocycles by condensation of 2-amino benzimidazole and 3-amino-1,2,4-triazole, as amine sources, with dimedone and different aldehydes in the presence of H6P2W18O(62).18H2O as a green and reusable catalyst in refluxing acetonitrile has been developed.