Prophylactic antibiotics (Abx) are used before liver surgery, and the influence of antibiotic pretreatment on hepatic ischemia–reperfusion injury (IRI) remains unclear. Hence, we explored the impact of Abx pretreatment on hepatic IRI in the present work. The gut microbiota has an essential role in hepatic bile acid (BA) metabolism, and we assumed that depletion of the gut microbiota could affect the composition of hepatic BAs and affect liver IRI. The IRI model demonstrated that Abx pretreatment attenuated liver IRI by alleviating cell apoptosis, reducing the inflammatory response, and decreasing the recruitment of CCR2+ monocytes. Mechanistically, Abx pretreatment reshaped the gut microbiota, especially decreasing the relative abundance of Firmicutes and increasing the relative abundance of Clostridium, which were related to the transformation of BAs and were consistent with the altered bile acid species (unconjugated BAs, especially UDCA). These altered BAs are known FXR agonists and lead to the activation of the farnesoid X receptor (FXR), which can directly bind to the FXR response element (FXRE) harbored in the TLR4 promoter and further suppress downstream mitogen-activated protein kinase (MAPK) and nuclear kappa B (NF-κB) pathways. Meanwhile, the CCL2–CCR2 axis was also involved in the process of FXR activation, as we confirmed both in vivo and in vitro. Importantly, we proved the importance of FXR in mice and clinical occlusion samples, which were inversely correlated with liver injury. Taken together, our study identified that Abx pretreatment before liver resection was a beneficial event by activating FXR, which might become a potential therapeutic target in treating liver injury.