An early deflected goal from Glen Kamara proved enough to send Rangers past Livingston and into the Betfred Cup semi-finals.
Rangers were far from comfortable at the Tony Macaroni Arena with their defence given plenty of trouble from the hosts.
But Livingston goalkeeper Matija Sarkic produced some good saves and Steven Gerrard's men got a firmer grip of the game in the final 20 minutes.
They had looked set for a more comfortable evening when Kamara took advantage of Nicky Devlin's poor clearance to send a left-footed shot in off the full-back from 18 yards inside five minutes.
But Livi soon had two penalty claims rejected by Don Robertson – firstly when Robbie Crawford went down under the challenge of Filip Helander and then when Devlin's header hit Joe Aribo from close range.
Rangers had failed to build on their early lead although Alfredo Morelos came close from 30 yards, and they lost Aribo to a head wound midway through the half after he was caught by Ricki Lamie's elbow in an aerial challenge. Steven Davis came on, with Lamie escaping punishment.
Sarkic kept the hosts in the game with an excellent one-handed stop to deny Scott Arfield after the midfielder was picked out by James Tavernier.
Gary Holt's side finished the half the stronger side with target man Lyndon Dykes causing real problems for Connor Goldson and Helander.
Aymen Souda and Keaghan Jacobs were both a yard off target from long range and Allan McGregor came out to stop the latter getting to Dykes' through-ball.
Helander was fortunate to get away with a challenge on Dykes as the striker tried to run through the middle of the Rangers defence, Robertson waving play on as the Swede upended the striker without appearing to get the ball.
The home side maintained their momentum after the break and had three excellent early chances.
Devlin breezed inside Borna Barisic and shot just wide before McGregor pushed away Lamie's close-range effort. Dykes then got ahead of both Goldson and Helander to race onto Jacobs' ball over the top, but the Australian lobbed just over with McGregor stranded.
Sheyi Ojo soon had three clear chances in quick succession on the break but Sarkic made two good saves before the wide man shot past.
The hosts were still well in the game and Souda hit the outside of the post after a Dykes flick-on.
Sarkic saved from Arfield and the introduction of Andy King in the 72nd minute brought some composure to the Rangers midfield with most of the remainder of the game being played in the Livi half.
No Data Analysis info