Incorporation of transversus abdominis plane (TAP) block into multimodal analgesia has been emphasized in Enhanced Recovery protocols (ERPs). However, benefit is limited in clinical practice. A potential explanation is the short duration of analgesia of standard local anesthetics. Herein, this randomized, double-blind, controlled trial evaluated whether TAPB with long-acting compound lidocaine hydrochloride injection reduces postoperative pain. 164 patients undergoing elective gynecological laparotomy under sevoflurane anesthesia randomly received ultrasound-guided TAP block with either saline, or ropivacaine, or compound lidocaine before anesthesia induction. The postoperative pain intensity (primary outcome) was evaluated by pain 11-point numerical rating scale. We also recorded sufentanil consumptions, time to first flatus, side-effects and hospital stay after surgery. We reported that pain scores at rest at postoperative 3h in group 0.375% ropivacaine was lower than that in group saline [mean 2.4 (SD 1.2) vs. 3.0 (1.0), p = 0.036]. Compared with saline, 0.4% and 0.6% compound lidocaine caused lower pain scores at rest at postoperative 12h [2.8 (0.9) vs. 2.1 (0.9) and 2.0 (0.9), p = 0.016 and p = 0.006]. Sufentanil usage for the first postoperative 48h was lower in group 0.6% compound lidocaine than group saline [24.2 (5.4) vs. 45.6 (7.5) µg, p < 0.001]. Time to first flatus and hospital stay after surgery was shortest and the incidence of postoperative nausea was lowest in patients receiving 0.6% compound lidocaine. TAP block with 0.6% compound lidocaine hydrochloride injection attenuates postoperative pain, reduces opioid consumption, accelerates gastrointestinal function recovery, and shortens length of hospital stay in patients after gynecological laparotomy. ClinicalTrials.gov, identifier: NCT04938882.