A series of new pyrimidine and quinazoline derivatives was synthesized by a Biginelli-like reaction of urea/thiourea, aldehyde, and ketone in the presence of hydrochloric acid as a catalyst. In a similar way, some novel diazatricyclo derivatives were obtained via a Biginelli-like reaction followed by an intramolecular Michael-type addition. The yields of products were reasonable after recrystallization from ethanol. All newly synthesized compounds were characterized using IR and NMR (1H and 13C) spectroscopy and elemental analysis. The antibacterial activity of these compounds was investigated against Staphylococcus aureus (RTCC, 1885), and Escherichia Coli (ATCC, 35922).