An efficient method has been developed for the synthesis of novel 5‐, 6‐ and 7‐membered ring (1H‐pyrrol‐2‐yl)aminolactams 5 a–f. This method featured Ugi‐4‐center‐3‐component reaction (U4 C3 C) followed by a post‐transformation reaction. All the newly synthesized (1H‐pyrrol‐2‐yl)aminolactams 5 a–f have been screened against six microbial species and the results revealed that these lactams exhibited moderate to good activity. These lactams were also tested in an in vitro for their antiviral activity against of HIV‐1 and HIV‐2 replication using MT‐4 cells. The testing results showed that compound 5 f is the only compound in the set lactams exhibiting a significant inhibition against HIV‐1 replication in cell line with EC50 value of 2.74±1.08 μM (CC50 of 18.93±4.0 μM), and SI 6. In addition, the compound 5 f was docked with essential proteins of HIV‐1 and HIV‐2 reverses transcriptase (RT), including HIV‐1 and HIV‐2 integrases strand proteins (PDB ID: 1EP4, 1FK9, 1HNV, 1VRU, 3DLE, 3DLG, and 3MEC). The docking results revealed that important hydrogen bond interactions and hydrophobic interactions were found between the compound 5 f and the essential amino acids residues of HIV‐1 and HIV‐2 (RT) proteins.