Rangers went three up against Midtjylland before emerging from a shaky second-half spell to earn a 4-2 victory in the first leg of the third qualifying round.
The Danes struck two quickfire goals themselves and Rangers looked rattled but Scott Arfield's calm finish gave them a healthy lead with 20 minutes remaining.
There were few clear-cut chances in the opening quarter but both teams showed attacking intent, the hosts mainly from set-pieces.
Former Celtic defender Erik Sviatchenko made a crucial interception as James Tavernier tried to find Morelos, and McGregor pushed Evander's searching ball past the post.
The Rangers goalkeeper then made a point-blank save from Sory Kaba's shot after the Danes had won three headers following a long throw into the six-yard box.
McGregor punched away the resulting corner under pressure and Jones embarked on a great run from his 18-yard box before crossing just in front of Arfield.
Morelos soon grabbed the opener as he got away from his marker to guide home Tavernier's brilliant swerving cross from seven yards.
Flanagan survived a handball claim in his box before Jones might have had a penalty after being clipped, but the winger soon set up the second in the 52nd minute.
The Northern Ireland international picked up a loose ball midway inside his own half and ran deep into home territory before feeding Aribo, who carried the ball into the box, steadied himself and fired into the far corner.
Jones soon ran at the full-back and fired a deflected effort that was tipped on to the bar and over, and the third goal came after the resulting corner was half-cleared towards Kamara on the edge of the box. The midfielder headed down to Morelos, who helped the bouncing ball on to the unmarked Katic and the Croatian supplied an excellent finish.
Rangers soon threatened to implode, though. They lost possession deep inside their half, Ryan Jack was beaten on the byline and Frank Onyeka eventually forced home the cutback on the turn in the 58th minute.
The Danes pulled another goal back five minutes later after working the ball from wide left to Kaba 20 yards out and the Guinea international fired into the bottom corner.
The hosts had their tails up and Rangers took time to settle but, once they had, they quickly regained a two-goal cushion.
Tavernier's pass got Morelos inside the full-back and Arfield trapped his cutback before passing the ball past a defender and the keeper into the net.
Jack, Flanagan, Aribo and Morelos were booked along with two opponents in a fractious finale but McGregor did not have much to do despite the home side piling men forward.