Uropathogenic Escherichia coli (UPEC) biofilm formation enables the organism to avoid the host immune system, resist antibiotics, and provide a reservoir for persistent infection. Once the biofilm is established, eradication of the infection becomes difficult. Therefore, strategies against UPEC biofilm are urgently required. In this study, we investigated the effect of allicin, isolated from garlic essential oil, on UPEC CFT073 and J96 biofilm formation and dispersal, along with its effect on UPEC adhesion ability and swimming motility. Sub-inhibitory concentrations (sub-MICs) of allicin decreased UPEC biofilm formation and affected its architecture. Allicin was also capable of dispersing biofilm. Furthermore, allicin decreased the bacterial adhesion ability and swimming motility, which are important for biofilm formation. Real-time quantitative polymerase chain reaction (RT-qPCR) revealed that allicin decreased the expression of UPEC type 1 fimbriae adhesin gene fimH. Docking studies suggested that allicin was located within the binding pocket of heptyl α-d-mannopyrannoside in FimH and formed hydrogen bonds with Phe1 and Asn135. In addition, allicin decreased the expression of the two-component regulatory systems (TCSs) cognate response regulator gene uvrY and increased the expression of the RNA binding global regulatory protein gene csrA of UPEC CFT073, which is associated with UPEC biofilm. The findings suggest that sub-MICs of allicin are capable of affecting UPEC biofilm formation and dispersal, and decreasing UPEC adhesion ability and swimming motility.