The use of erector spinae plane block and rectus sheath block for postoperative analgesia in midline abdominal procedures is becoming more common. However, the most effective and appropriate method remains unclear. We aimed to compare the postoperative analgesic effecacy of ultrasound-guided bilateral erector spinae plane blocks with rectus sheath blocks for midline abdominal surgery in a low- and middle-income country. We allocated randomly 72 patients aged 18-65 y undergoing midline abdominal surgery to an erector spinae plane block (n = 36) or a rectus sheath block (n = 36) utilising a prospective, parallel study design. Patients, care providers and outcome assessors were blinded to the interventions. The primary outcome measures were total postoperative analgesia consumption, postoperative pain severity and time to first rescue analgesic administration. Secondary outcomes included the incidence of postoperative complications and adverse events. Of 78 patients assessed for eligibility, six were excluded, leaving 72 for analysis. Patients allocated to erector spinae plane block had a lower mean (SD) postoperative opioid consumption compared with those allocated to rectus sheath block (3.5 (8.7) morphine milligram equivalents vs. 8.2 (2.8) morphine milligram equivalents, respectively; p = 0.003). Time to first analgesic request was greater in patients allocated to erector spinae plane block compared with those allocated to rectus sheath block (mean (95%CI) 16 (13-17) h vs. 12 (11-13) h, respectively; p < 0.001). There were no block-related complications in either group. Erector spinae plane blocks are more effective than rectus sheath blocks for the management of postoperative pain following midline abdominal surgery. Integration of erector spinae plane blocks into multimodal opioid-sparing analgesic strategies after midline abdominal surgeries may promote enhanced patient recovery in low-and middle-income countries.