A library of 112 4(5)-aryl-2-amino-1H-imidazoles, 4,5-diphenyl-2-amino-1H-imidazoles, and N1-substituted 4(5)-phenyl-2-aminoimidazoles was synthesized and tested for the antagonistic effect against biofilm formation by Salmonella Typhimurium and Pseudomonas aeruginosa. The substitution pattern of the 4(5)-phenyl group and the nature of the N1-substituent were found to have a major effect on the biofilm inhibitory activity. The most active compounds of this series were shown to inhibit the biofilm formation at low micromolar concentrations. Furthermore, the influence of 6 imidazo[1,2-a]pyrimidines and 18 imidazo[1,2-a]pyrimidinium salts on the biofilm formation was tested. These compounds are the chemical precursors of the 2-aminoimidazoles in our synthesis pathway. A good correlation was found between the activity of the imidazo[1,2-a]pyrimidinium salts and their corresponding 2-aminoimidazoles, supporting the hypothesis that the imidazo[1,2-a]pyrimidinium salts are possibly cleaved by cellular nucleophiles to form the active 2-aminoimidazoles. However, the imidazo[1,2-a]pyrimidines did not show any biofilm inhibitory activity, indicating that these molecules are not susceptible to in situ degradation to 2-aminoimidazoles. Finally, we demonstrated the lack of biofilm inhibitory activity of an array of 37 2N-substituted 2-aminopyrimidines, which are the chemical precursors of the imidazo[1,2-a]pyrimidinium salts in our synthesis pathway.