Goalless at the break at Ibrox, it was Morton who took the lead from the penalty spot early in the second-half before Cyriel Dessers converted a Rangers spot-kick shortly after.
Substitute Danilo found the target with 20 minutes of the game remaining to ensure the Light Blues a spot in the last eight of the competition.
Manager Michael Beale made a number of changes to the team which faced Servette midweek as Dujon Sterling, Leon Balogun, Johnly Yfeko, Kieran Dowell, Rabbi Matondo, John Lundstram, Cyriel Dessers and Sam Lammers all came into the starting line-up.
That meant Rangers started with Jack Butland in goal and a back four of Dujon Sterling, Connor Goldson, Leon Balogun and Johnly Yfeko.
Jose Cifuentes retained his place in midfield, alongside Kieran Dowell and John Lundstram, with Cyriel Dessers, Sam Lammers and Rabbi Matondo leading the line.
For Matondo, Sterling and Yfeko, it was a first start of the season in this cup tie as the manager named several changes in what is a busy month for the squad.
It was Rangers who got the action underway at Ibrox, and there was an early chance for Rabbi Matondo to open the scoring inside the opening three minutes. John Lundstram picked out the winger with a ball over the top which Matondo controlled well before driving into the box but his strike was blocked by Jamie MacDonald.
Michael Beale’s men were dominating the early stages at Ibrox with John Lundstram firing a shot from the edge of the area just over shortly after.
Dujon Sterling was next to create an opportunity for the Light Blues as he beat the defender on the right before delivering a dangerous ball into the box in search of Cyriel Dessers. Dessers took a touch and hit the ball on the volley but MacDonald matched the strike with a good block.
The visitors had their first chance of the afternoon with 18 minutes played at Ibrox. A free-kick on the edge of the box provided the opportunity for Robbie Muirhead as he looked to curl the ball beyond Butland but the goalkeeper was down quick to get a strong connection on the strike at the right hand post.
Cyriel Dessers thought he had given Rangers the lead as he raced through on goal alongside Morton defender Darragh O’Connor. The striker managed to break forward and get a touch to slot beyond Jamie MacDonald but the referee disallowed the strike for a foul on O’Connor in the build-up.
In another Rangers attack, Rabbi Matondo raced down the left, driving into the box and trying a shot at goal from a tight angle but it was cleared off the line by a Morton defender.
Just before half-time, Gers were awarded a free-kick in a central position around 25 yards out. Kieran Dowell stepped up to the set-piece and curled a left-footed strike towards goal which looked to be heading for the back of the net but MacDonald was able to push it wide for a corner.
Five minutes into the second-half, Greenock Morton were awarded a penalty following a VAR check. In the follow on from a Morton corner, Cyriel Dessers clipped former Ranger Kirk Broadoot inside the box, with David Dickinson called over to review the footage.
After pointing to the spot, Morton captain Grant Gillespie stepped up and sent the right-footed penalty low beyond Jack Butland to give the Championship side the lead.
There was another VAR check just minutes later, as Kirk Broadfoot had a hold of Leon Balogun’s shirt as he tried to get on the end of a Jose Cifuentes free-kick.
As the VAR check was going on, Beale turned to his bench making a triple substitution with Dujon Sterling, Leon Balogun and Sam Lammers making way for Ianis Hagi, Abdallah Sima and Danillo.
After Dickinson pointed to the spot for the second time of the afternoon, Cyriel Dessers stepped up in the absence of usual penalty taker James Tavernier, and dispatched the penalty sending MacDonald the wrong way and drawing Rangers back level.
Dessers was involved again as Michael Beale’s men took the lead in this cup tie. The striker showed huge desire to regain possession in the middle of the pitch before picking out Danilo who had made a run into the box. The Brazilian took a touch to find space for a shot and finished low beyond MacDonald.
The Morton keeper denied Ianis Hagi shortly after as tipped his shot over the bar as Rangers started to find their rhythm at Ibrox.
Abdallah Sima saw a header come back off the bar as they piled the pressure on their opponents before Hagi came agonisingly close again as he turned well after being fed in by Sima but it was just over the bar from the Romanian.
MacDonald pushed wide a Cifuentes effort late in the game as Rangers looked to finish off the tie at Ibrox as the fourth official indicated eight minutes of additional time.
Michael Beale’s men saw out the injury time to progress to the quarter-finals of the Viaplay Cup, with attention now turning to Tuesday night’s UEFA Champions League play-off against PSV Eindhoven.
RANGERS: Butland, Sterling (Danilo, 57), Goldson, Balogun (Sima, 57), Yfeko, Cifuentes, Dowell, Lundstram, Matondo (Devine, 81), Lammers (Hagi, 57), Dessers (Roofe, 81).
Subs: McCrorie, Lawrence, King, Rice.
Greenock Morton: MacDonald, O’Connor, Waters, Blues, Muirhead, Crawford, Broadfoot, McGrattan (Bearne, 76), Power, Gillespie (King, 69), Oakley.
Subs: Mullen, Baird.