The Edinburgh side took the lead early in the match through a Lawrence Shankland header, but a James Tavernier penalty and Danilo’s goal secured the victory for Rangers.
There was one change from the midweek draw with Sparta Prague as Ridvan came into the starting XI in place of John Souttar.
That meant Rangers lined-up at Ibrox with Jack Butland in goal and a back four of James Tavernier, Connor Goldson, Ben Davies and Ridvan.
John Lundstram, Nico Raskin and Sam Lammers were in midfield, with Todd Cantwell, Abdallah Sima and Cyriel Dessers completing the starting XI.
With less than five minutes on the clock, it was the visitors who took the lead at Ibrox with the first chance of the game. Alex Cochrane whipped an inviting ball into the box with Lawrence Shankland able to guide a header beyond Jack Butland and into the back of the net.
Rangers looked for a quick response, with Cyriel Dessers picking out Todd Cantwell with a pass across the box but a Hearts defender was able to get a touch before Zander Clark gathered.
From a James Tavernier corner, the Light Blues had their best chance of the game so far to equalise as Cyriel Dessers got a touch on a Connor Goldson header to divert it goalwards but Hearts captain Lawrence Shankland was on hand to clear off the line.
Kenneth Vargas had a strike drift over the bar for Hearts, before John Lundstram released a powerful strike from the edge of the box which was deflected wide.
In first-half injury time, Rangers were awarded a penalty as Todd Cantwell was wiped out in the box by Toby Sibbick as he drove forward looking to create an opening.
Captain James Tavernier stepped-up to the spot but he was unable to convert as his right-footed spot kick bounced back off the post before the danger was cleared.
At half-time, Clement made a change up front as Cyriel Dessers was replaced by Danilo.
Rangers were searching for an early goal after the break, with John Lundstram coming close with a long-range effort from outside the box but it was just wide of the target..
With 57 minutes on the clock, Sam Lammers had a good chance to level the scoring as he got on the end of a cut-back from Ridvan, but he was unable to keep his strike down as it drifted over the bar.
Rangers were pushing for an equaliser as Nico Raskin came close with a powerful strike as he got on the end of a ball which was pushed away by goalkeeper Zander Clark however the Belgian’s effort was just wide of the post.
It was the last action for Raskin as he had to be stretchered off after picking up an injury after taking the shot and was replaced by Scott Wright.
Ryan Jack was introduced with 82 minutes on the clock as he replaced Sam Lammers for the final period of the match for what was his 200th Rangers appearance.
With just two minutes remaining, Rangers were awarded their second penalty of the match. At a corner, Connor Goldson was fouled in the box with referee John Beaton called to the VAR monitor to review the footage before pointing to the spot.
Tavernier stepped up again and this time made no mistake in sending the ball beyond Clark to draw Rangers level.
With nine minutes added, Clement’s men were searching for a winning goal late in the game with the Ibrox crowd behind them.
The goal did come with 93 minutes played as Tavernier’s ball found Danilo in the box and the striker headed beyond Clark with Ibrox erupting.
RANGERS: Butland, Tavernier, Goldson, Davies, Ridvan, Lundstram, Raskin (Wright, 64), Lammers (Jack, 82), Cantwell (McCausland, 76), Sima, Dessers (Danilo, 46).
Subs: McCrorie, Souttar, Cifuentes, Dowell, Devine.
Hearts: Clark, Kent, Baningime (Devlin, 60), Grant (Forrest, 60), Nieuwenhof (Haring, 78), Shankland, Rowles, Cochrane, Sibbick (Halliday, 78), Offiah (Kingsley, 39), Vargas.
Subs: McGovern, Boyce, Oda, Denholm.